1 | <?php |
||
14 | class Directory implements FileInterface |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * Full path to the directory. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | private $path; |
||
23 | |||
24 | /** |
||
25 | * Create a new instance with a path. |
||
26 | * |
||
27 | * @param string $path Optional path pointed to by new instance. Path does not have to exist. |
||
28 | */ |
||
29 | 6 | public function __construct(string $path = null) |
|
33 | |||
34 | /** |
||
35 | * Used to perform copies and moves. |
||
36 | * |
||
37 | * @param string $operation |
||
38 | * @param string $destination |
||
39 | * @throws FileNotFoundException |
||
40 | * @throws FilesystemException |
||
41 | * @throws \ntentan\utils\exceptions\FileAlreadyExistsException |
||
42 | * @throws \ntentan\utils\exceptions\FileNotReadableException |
||
43 | * @throws \ntentan\utils\exceptions\FileNotWriteableException |
||
44 | */ |
||
45 | 2 | private function directoryOperation(string $operation, string $destination):void |
|
59 | |||
60 | /** |
||
61 | * Recursively copies directory and its contents to destination. |
||
62 | * |
||
63 | * @param string $destination |
||
64 | * @throws FileNotFoundException |
||
65 | * @throws FilesystemException |
||
66 | * @throws \ntentan\utils\exceptions\FileAlreadyExistsException |
||
67 | * @throws \ntentan\utils\exceptions\FileNotReadableException |
||
68 | * @throws \ntentan\utils\exceptions\FileNotWriteableException |
||
69 | */ |
||
70 | 1 | public function copyTo(string $destination): void |
|
74 | |||
75 | /** |
||
76 | * Recursively get the size of all contents in the directory. |
||
77 | * |
||
78 | * @return integer |
||
79 | * @throws FileNotFoundException |
||
80 | * @throws FilesystemException |
||
81 | * @throws \ntentan\utils\exceptions\FileNotReadableException |
||
82 | */ |
||
83 | 1 | public function getSize() : int |
|
87 | |||
88 | /** |
||
89 | * Recursively move a directory and its contents to another location. |
||
90 | * |
||
91 | * @param string $destination |
||
92 | * @throws FileNotFoundException |
||
93 | * @throws FilesystemException |
||
94 | * @throws \ntentan\utils\exceptions\FileAlreadyExistsException |
||
95 | * @throws \ntentan\utils\exceptions\FileNotReadableException |
||
96 | * @throws \ntentan\utils\exceptions\FileNotWriteableException |
||
97 | */ |
||
98 | 1 | public function moveTo(string $destination) : void |
|
104 | |||
105 | /** |
||
106 | * Create the directory pointed to by path. |
||
107 | * |
||
108 | * @param int $permissions |
||
109 | * @throws \ntentan\utils\exceptions\FileAlreadyExistsException |
||
110 | * @throws \ntentan\utils\exceptions\FileNotWriteableException |
||
111 | */ |
||
112 | 2 | public function create($recursive=false, $permissions = 0755) |
|
137 | |||
138 | /** |
||
139 | * Recursively delete the directory and all its contents. |
||
140 | * |
||
141 | * @throws FileNotFoundException |
||
142 | * @throws FilesystemException |
||
143 | * @throws \ntentan\utils\exceptions\FileNotReadableException |
||
144 | */ |
||
145 | 2 | public function delete() : void |
|
150 | |||
151 | /** |
||
152 | * Get the path of the directory. |
||
153 | * |
||
154 | * @return string |
||
155 | */ |
||
156 | public function getPath() : string |
||
160 | |||
161 | /** |
||
162 | * Get the files in the directory. |
||
163 | * |
||
164 | * @throws FilesystemException |
||
165 | * @throws \ntentan\utils\exceptions\FileNotFoundException |
||
166 | * @throws \ntentan\utils\exceptions\FileNotReadableException |
||
167 | * @return array<FileInterface> |
||
|
|||
168 | */ |
||
169 | 5 | public function getFiles() : FileCollection |
|
183 | |||
184 | 3 | public function __toString() |
|
188 | } |
||
189 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.