Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
3 * Jingga
4 *
5 * PHP Version 8.1
6 *
7 * @package   phpOMS\System\File
8 * @copyright Dennis Eichhorn
9 * @license   OMS License 2.0
10 * @version   1.0.0
11 * @link      https://jingga.app
12 */
13declare(strict_types=1);
14
15namespace phpOMS\System\File;
16
17/**
18 * Filesystem class.
19 *
20 * Performing operations on the file system
21 *
22 * @package phpOMS\System\File
23 * @license OMS License 2.0
24 * @link    https://jingga.app
25 * @since   1.0.0
26 */
27interface ContainerInterface
28{
29    /**
30     * Get amount of sub-resources.
31     *
32     * A file will always return 1 as it doesn't have any sub-resources.
33     *
34     * @param bool $recursive Should count also sub-sub-resources
35     *
36     * @return int
37     *
38     * @since 1.0.0
39     */
40    public function getCount(bool $recursive = false) : int;
41
42    /**
43     * Get size of resource.
44     *
45     * @param bool $recursive Should include sub-sub-resources
46     *
47     * @return int
48     *
49     * @since 1.0.0
50     */
51    public function getSize(bool $recursive = false) : int;
52
53    /**
54     * Get name of the resource.
55     *
56     * @return string
57     *
58     * @since 1.0.0
59     */
60    public function getName() : string;
61
62    /**
63     * Get base name of the resource incl. extension if available.
64     *
65     * @return string
66     *
67     * @since 1.0.0
68     */
69    public function getBasename() : string;
70
71    /**
72     * Get absolute path of the resource.
73     *
74     * @return string
75     *
76     * @since 1.0.0
77     */
78    public function getPath() : string;
79
80    /**
81     * Get the parent path of the resource.
82     *
83     * The parent resource path is always a directory.
84     *
85     * @return ContainerInterface
86     *
87     * @since 1.0.0
88     */
89    public function getParent() : self;
90
91    /**
92     * Create resource at destination path.
93     *
94     * @return bool True on success and false on failure
95     *
96     * @since 1.0.0
97     */
98    public function createNode() : bool;
99
100    /**
101     * Copy resource to different location.
102     *
103     * @param string $to        Path of the resource to copy to
104     * @param bool   $overwrite Overwrite/replace existing file
105     *
106     * @return bool True on success and false on failure
107     *
108     * @since 1.0.0
109     */
110    public function copyNode(string $to, bool $overwrite = false) : bool;
111
112    /**
113     * Move resource to different location.
114     *
115     * @param string $to        Path of the resource to move to
116     * @param bool   $overwrite Overwrite/replace existing file
117     *
118     * @return bool True on success and false on failure
119     *
120     * @since 1.0.0
121     */
122    public function moveNode(string $to, bool $overwrite = false) : bool;
123
124    /**
125     * Delete resource at destination path.
126     *
127     * @return bool True on success and false on failure
128     *
129     * @since 1.0.0
130     */
131    public function deleteNode() : bool;
132
133    /**
134     * Get the datetime when the resource got created.
135     *
136     * @return \DateTimeImmutable
137     *
138     * @since 1.0.0
139     */
140    public function getCreatedAt() : \DateTimeImmutable;
141
142    /**
143     * Get the datetime when the resource got last modified.
144     *
145     * @return \DateTime
146     *
147     * @since 1.0.0
148     */
149    public function getChangedAt() : \DateTime;
150
151    /**
152     * Get the owner id of the resource.
153     *
154     * @return string
155     *
156     * @since 1.0.0
157     */
158    public function getOwner() : string;
159
160    /**
161     * Get the permissions id of the resource.
162     *
163     * @return int Permissions (e.g. 0755);
164     *
165     * @since 1.0.0
166     */
167    public function getPermission() : int;
168
169    /**
170     * (Re-)Initialize resource
171     *
172     * This is used in order to initialize all resources.
173     * Sub-sub-resources are only initialized once they are needed.
174     *
175     * @return void
176     *
177     * @since 1.0.0
178     */
179    public function index() : void;
180}