1 | <?php |
||
17 | class Directory implements FileInterface |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * Full path to the directory. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | private $path; |
||
26 | |||
27 | /** |
||
28 | * Create a new instance with a path. |
||
29 | * |
||
30 | * @param string $path Optional path pointed to by new instance. Path does not have to exist. |
||
31 | */ |
||
32 | 6 | public function __construct(string $path = null) |
|
36 | |||
37 | /** |
||
38 | * Used to perform copies and moves. |
||
39 | * |
||
40 | * @param string $operation |
||
41 | * @param string $destination |
||
42 | * @throws FileNotFoundException |
||
43 | * @throws FilesystemException |
||
44 | * @throws FileAlreadyExistsException |
||
45 | * @throws FileNotReadableException |
||
46 | * @throws FileNotWriteableException |
||
47 | */ |
||
48 | 2 | private function directoryOperation(string $operation, string $destination):void |
|
64 | |||
65 | /** |
||
66 | * Recursively copies directory and its contents to destination. |
||
67 | * |
||
68 | * @param string $destination |
||
69 | * @throws FileNotFoundException |
||
70 | * @throws FilesystemException |
||
71 | * @throws FileAlreadyExistsException |
||
72 | * @throws FileNotReadableException |
||
73 | * @throws FileNotWriteableException |
||
74 | */ |
||
75 | 1 | public function copyTo(string $destination): void |
|
79 | |||
80 | /** |
||
81 | * Recursively get the size of all contents in the directory. |
||
82 | * |
||
83 | * @return integer |
||
84 | * @throws FileNotFoundException |
||
85 | * @throws FilesystemException |
||
86 | * @throws FileNotReadableException |
||
87 | */ |
||
88 | 1 | public function getSize() : int |
|
92 | |||
93 | /** |
||
94 | * Recursively move a directory and its contents to another location. |
||
95 | * |
||
96 | * @param string $destination |
||
97 | * @throws FileNotFoundException |
||
98 | * @throws FilesystemException |
||
99 | * @throws FileAlreadyExistsException |
||
100 | * @throws FileNotReadableException |
||
101 | * @throws FileNotWriteableException |
||
102 | */ |
||
103 | 1 | public function moveTo(string $destination) : void |
|
109 | |||
110 | /** |
||
111 | * Create the directory pointed to by path. |
||
112 | * |
||
113 | * @param int $permissions |
||
114 | * @throws FileAlreadyExistsException |
||
115 | * @throws FileNotWriteableException |
||
116 | */ |
||
117 | 2 | public function create($recursive=false, $permissions = 0755) |
|
135 | |||
136 | /** |
||
137 | * Recursively delete the directory and all its contents. |
||
138 | * |
||
139 | * @throws FileNotFoundException |
||
140 | * @throws FilesystemException |
||
141 | * @throws FileNotReadableException |
||
142 | */ |
||
143 | 2 | public function delete() : void |
|
148 | |||
149 | /** |
||
150 | * Get the path of the directory. |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | 1 | public function getPath() : string |
|
158 | |||
159 | /** |
||
160 | * Get the files in the directory. |
||
161 | * |
||
162 | * @throws FilesystemException |
||
163 | * @throws FileNotFoundException |
||
164 | * @throws FileNotReadableException |
||
165 | * @return FileCollection | array<string> |
||
166 | */ |
||
167 | 5 | public function getFiles($recursive=false, $returnStrings=false) |
|
184 | |||
185 | 3 | public function __toString() |
|
189 | } |
||
190 |