1 | <?php |
||
18 | class Directory implements FileInterface |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * Full path to the directory. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | private $path; |
||
27 | |||
28 | /** |
||
29 | * Create a new instance with a path. |
||
30 | * |
||
31 | * @param string $path Optional path pointed to by new instance. Path does not have to exist. |
||
32 | */ |
||
33 | 6 | public function __construct(string $path = null) |
|
37 | |||
38 | /** |
||
39 | * Recursively copies directory and its contents to destination. |
||
40 | * |
||
41 | * @param string $destination |
||
42 | * @throws FileNotFoundException |
||
43 | * @throws FilesystemException |
||
44 | * @throws FileAlreadyExistsException |
||
45 | * @throws FileNotReadableException |
||
46 | * @throws FileNotWriteableException |
||
47 | */ |
||
48 | 1 | public function copyTo(string $destination, string $overwite = self::OVERWRITE_ALL): void |
|
53 | |||
54 | /** |
||
55 | * Recursively get the size of all contents in the directory. |
||
56 | * |
||
57 | * @return integer |
||
58 | * @throws FileNotFoundException |
||
59 | * @throws FilesystemException |
||
60 | * @throws FileNotReadableException |
||
61 | */ |
||
62 | 1 | public function getSize() : int |
|
66 | |||
67 | /** |
||
68 | * Recursively move a directory and its contents to another location. |
||
69 | * |
||
70 | * @param string $destination |
||
71 | * @throws FileNotFoundException |
||
72 | * @throws FilesystemException |
||
73 | * @throws FileAlreadyExistsException |
||
74 | * @throws FileNotReadableException |
||
75 | * @throws FileNotWriteableException |
||
76 | */ |
||
77 | 1 | public function moveTo(string $destination, string $overwite = self::OVERWRITE_ALL) : void |
|
84 | |||
85 | /** |
||
86 | * Create the directory pointed to by path. |
||
87 | * |
||
88 | * @param int $permissions |
||
89 | * @return Directory |
||
90 | * @throws FileAlreadyExistsException |
||
91 | * @throws FileNotWriteableException |
||
92 | */ |
||
93 | 2 | public function create($recursive=false, $permissions = 0755) |
|
113 | |||
114 | public function createIfNotExists($recursive=false, $permissions = 0755) |
||
123 | |||
124 | /** |
||
125 | * Recursively delete the directory and all its contents. |
||
126 | * |
||
127 | * @throws FileNotFoundException |
||
128 | * @throws FilesystemException |
||
129 | * @throws FileNotReadableException |
||
130 | */ |
||
131 | 2 | public function delete() : void |
|
136 | |||
137 | /** |
||
138 | * Get the path of the directory. |
||
139 | * |
||
140 | * @return string |
||
141 | */ |
||
142 | 1 | public function getPath() : string |
|
146 | |||
147 | /** |
||
148 | * Get the files in the directory. |
||
149 | * |
||
150 | * @throws FilesystemException |
||
151 | * @throws FileNotFoundException |
||
152 | * @throws FileNotReadableException |
||
153 | * @return FileCollection | array<string> |
||
154 | */ |
||
155 | 5 | public function getFiles($recursive=false, $returnStrings=false) |
|
172 | |||
173 | 3 | public function __toString() |
|
177 | } |
||
178 |