Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
AbstractStorage | |
100.00% |
5 / 5 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setAdapter | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getAdapter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
adapter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBaseDir | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getBaseDir | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getCurrentDir | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
chdir | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
mkdir | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
rmdir | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
listAll | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
listDirs | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
listFiles | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
putFile | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
putFileContents | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
uploadFile | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
copyFile | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
copyFileToExternal | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
copyFileFromExternal | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
moveFileToExternal | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
moveFileFromExternal | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
renameFile | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
replaceFileContents | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
deleteFile | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
fetchFile | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
fetchFileInfo | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
fileExists | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
isDir | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
isFile | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getFileSize | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getFileType | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getFileMTime | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
md5File | n/a |
0 / 0 |
n/a |
0 / 0 |
0 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Storage; |
15 | |
16 | use Pop\Storage\Adapter\AbstractAdapter; |
17 | |
18 | /** |
19 | * Storage abstract class |
20 | * |
21 | * @category Pop |
22 | * @package Pop\Storage |
23 | * @author Nick Sagona, III <dev@nolainteractive.com> |
24 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
25 | * @license http://www.popphp.org/license New BSD License |
26 | * @version 2.0.0 |
27 | */ |
28 | abstract class AbstractStorage implements StorageInterface |
29 | { |
30 | |
31 | /** |
32 | * Storage adapter |
33 | * @var ?AbstractAdapter |
34 | */ |
35 | protected ?AbstractAdapter $adapter = null; |
36 | |
37 | /** |
38 | * Constructor |
39 | * |
40 | * @param AbstractAdapter $adapter |
41 | */ |
42 | public function __construct(AbstractAdapter $adapter) |
43 | { |
44 | $this->setAdapter($adapter); |
45 | } |
46 | |
47 | /** |
48 | * Set adapter |
49 | * |
50 | * @param AbstractAdapter $adapter |
51 | * @return AbstractStorage |
52 | */ |
53 | public function setAdapter(AbstractAdapter $adapter): AbstractStorage |
54 | { |
55 | $this->adapter = $adapter; |
56 | return $this; |
57 | } |
58 | |
59 | /** |
60 | * Get adapter |
61 | * |
62 | * @return ?AbstractAdapter |
63 | */ |
64 | public function getAdapter(): ?AbstractAdapter |
65 | { |
66 | return $this->adapter; |
67 | } |
68 | |
69 | /** |
70 | * Get adapter (alias) |
71 | * |
72 | * @return ?AbstractAdapter |
73 | */ |
74 | public function adapter(): ?AbstractAdapter |
75 | { |
76 | return $this->adapter; |
77 | } |
78 | |
79 | /** |
80 | * Set base directory |
81 | * |
82 | * @param ?string $directory |
83 | * @return void |
84 | */ |
85 | abstract public function setBaseDir(?string $directory = null): void; |
86 | |
87 | /** |
88 | * Get base directory |
89 | * |
90 | * @return ?string |
91 | */ |
92 | abstract public function getBaseDir(): ?string; |
93 | |
94 | /** |
95 | * Get current directory |
96 | * |
97 | * @return ?string |
98 | */ |
99 | abstract public function getCurrentDir(): ?string; |
100 | |
101 | /** |
102 | * Change directory |
103 | * |
104 | * @param ?string $directory |
105 | * @return void |
106 | */ |
107 | abstract public function chdir(?string $directory = null): void; |
108 | |
109 | /** |
110 | * Make directory |
111 | * |
112 | * @param string $directory |
113 | * @return void |
114 | */ |
115 | abstract public function mkdir(string $directory): void; |
116 | |
117 | /** |
118 | * Remove a directory |
119 | * |
120 | * @param string $directory |
121 | * @return void |
122 | */ |
123 | abstract public function rmdir(string $directory): void; |
124 | |
125 | /** |
126 | * List all |
127 | * |
128 | * @param ?string $search |
129 | * @return array |
130 | */ |
131 | abstract public function listAll(?string $search = null): array; |
132 | |
133 | /** |
134 | * List directories |
135 | * |
136 | * @param ?string $search |
137 | * @return array |
138 | */ |
139 | abstract public function listDirs(?string $search = null): array; |
140 | |
141 | /** |
142 | * List files |
143 | * |
144 | * @param ?string $search |
145 | * @return array |
146 | */ |
147 | abstract public function listFiles(?string $search = null): array; |
148 | |
149 | /** |
150 | * Put file |
151 | * |
152 | * @param string $fileFrom |
153 | * @param bool $copy |
154 | * @return void |
155 | */ |
156 | abstract public function putFile(string $fileFrom, bool $copy = true): void; |
157 | |
158 | /** |
159 | * Put file contents |
160 | * |
161 | * @param string $filename |
162 | * @param string $fileContents |
163 | * @return void |
164 | */ |
165 | abstract public function putFileContents(string $filename, string $fileContents): void; |
166 | |
167 | /** |
168 | * Upload file from server request $_FILES['file'] |
169 | * |
170 | * @param array $file |
171 | * @return void |
172 | */ |
173 | abstract public function uploadFile(array $file): void; |
174 | |
175 | /** |
176 | * Copy file |
177 | * |
178 | * @param string $sourceFile |
179 | * @param string $destFile |
180 | * @return void |
181 | */ |
182 | abstract public function copyFile(string $sourceFile, string $destFile): void; |
183 | |
184 | /** |
185 | * Copy file to a location external to the current location |
186 | * |
187 | * @param string $sourceFile |
188 | * @param string $externalFile |
189 | * @return void |
190 | */ |
191 | abstract public function copyFileToExternal(string $sourceFile, string $externalFile): void; |
192 | |
193 | /** |
194 | * Copy file from a location external to the current location |
195 | * |
196 | * @param string $externalFile |
197 | * @param string $destFile |
198 | * @return void |
199 | */ |
200 | abstract public function copyFileFromExternal(string $externalFile, string $destFile): void; |
201 | |
202 | /** |
203 | * Move file to a location external to the current location |
204 | * |
205 | * @param string $sourceFile |
206 | * @param string $externalFile |
207 | * @return void |
208 | */ |
209 | abstract public function moveFileToExternal(string $sourceFile, string $externalFile): void; |
210 | |
211 | /** |
212 | * Move file from a location external to the current location |
213 | * |
214 | * @param string $externalFile |
215 | * @param string $destFile |
216 | * @return void |
217 | */ |
218 | abstract public function moveFileFromExternal(string $externalFile, string $destFile): void; |
219 | |
220 | /** |
221 | * Rename file |
222 | * |
223 | * @param string $oldFile |
224 | * @param string $newFile |
225 | * @return void |
226 | */ |
227 | abstract public function renameFile(string $oldFile, string $newFile): void; |
228 | |
229 | /** |
230 | * Replace file |
231 | * |
232 | * @param string $filename |
233 | * @param string $fileContents |
234 | * @return void |
235 | */ |
236 | abstract public function replaceFileContents(string $filename, string $fileContents): void; |
237 | |
238 | /** |
239 | * Delete file |
240 | * |
241 | * @param string $filename |
242 | * @return void |
243 | */ |
244 | abstract public function deleteFile(string $filename): void; |
245 | |
246 | /** |
247 | * Fetch file contents |
248 | * |
249 | * @param string $filename |
250 | * @return mixed |
251 | */ |
252 | abstract public function fetchFile(string $filename): mixed; |
253 | |
254 | /** |
255 | * Fetch file info |
256 | * |
257 | * @param string $filename |
258 | * @return array |
259 | */ |
260 | abstract public function fetchFileInfo(string $filename): array; |
261 | |
262 | /** |
263 | * File exists |
264 | * |
265 | * @param string $filename |
266 | * @return bool |
267 | */ |
268 | abstract public function fileExists(string $filename): bool; |
269 | |
270 | /** |
271 | * Check if is a dir |
272 | * |
273 | * @param string $directory |
274 | * @return bool |
275 | */ |
276 | abstract public function isDir(string $directory): bool; |
277 | |
278 | /** |
279 | * Check if is a file |
280 | * |
281 | * @param string $filename |
282 | * @return bool |
283 | */ |
284 | abstract public function isFile(string $filename): bool; |
285 | |
286 | /** |
287 | * Get file size |
288 | * |
289 | * @param string $filename |
290 | * @return int|bool |
291 | */ |
292 | abstract public function getFileSize(string $filename): int|bool; |
293 | |
294 | /** |
295 | * Get file type |
296 | * |
297 | * @param string $filename |
298 | * @return string|bool |
299 | */ |
300 | abstract public function getFileType(string $filename): string|bool; |
301 | |
302 | /** |
303 | * Get file modified time |
304 | * |
305 | * @param string $filename |
306 | * @return int|string|bool |
307 | */ |
308 | abstract public function getFileMTime(string $filename): int|string|bool; |
309 | |
310 | /** |
311 | * Create MD5 checksum of the file |
312 | * |
313 | * @param string $filename |
314 | * @return string|bool |
315 | */ |
316 | abstract public function md5File(string $filename): string|bool; |
317 | |
318 | } |