1 | <?php |
||
7 | class BackupFilesystem implements BackupFilesystemInterface |
||
8 | { |
||
9 | private const OS_UNKNOWN = 1; |
||
10 | private const OS_WIN = 2; |
||
11 | private const OS_LINUX = 3; |
||
12 | private const OS_OSX = 4; |
||
13 | |||
14 | /** |
||
15 | * Ignored files. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | public static $ignoredFiles = [ |
||
20 | '.gitignore', |
||
21 | '.gitkeep' |
||
22 | ]; |
||
23 | |||
24 | /** |
||
25 | * Check path exists. |
||
26 | * |
||
27 | * @param string $path |
||
28 | * |
||
29 | * @return bool |
||
30 | */ |
||
31 | public function checkPathExists($path): bool |
||
39 | |||
40 | /** |
||
41 | * Check file exists. |
||
42 | * |
||
43 | * @param string $filepath |
||
44 | * |
||
45 | * @return bool |
||
46 | */ |
||
47 | public function checkFileExists($filepath): bool |
||
59 | |||
60 | /** |
||
61 | * Check if file is empty. |
||
62 | * |
||
63 | * @param string $filepath |
||
64 | * |
||
65 | * @return bool |
||
66 | */ |
||
67 | public function checkFileEmpty($filepath): bool |
||
71 | |||
72 | /** |
||
73 | * Remove file. |
||
74 | * |
||
75 | * @param string $filepath |
||
76 | * |
||
77 | * @return void |
||
78 | */ |
||
79 | public function removeFile($filepath): void |
||
83 | |||
84 | /** |
||
85 | * Write a compressed file. |
||
86 | * |
||
87 | * @param string $compressedFilepath |
||
88 | * @param string $filepath |
||
89 | * |
||
90 | * @return void |
||
91 | */ |
||
92 | public function writeCompressedFile($compressedFilepath, $filepath): void |
||
98 | |||
99 | /** |
||
100 | * Write an uncompressed file. |
||
101 | * |
||
102 | * @param string $uncompressedFilepath |
||
103 | * @param string $filepath |
||
104 | * |
||
105 | * @return void |
||
106 | */ |
||
107 | public function writeUncompressedFile($uncompressedFilepath, $filepath): void |
||
113 | |||
114 | /** |
||
115 | * Get the operating system. |
||
116 | * |
||
117 | * @return int |
||
118 | */ |
||
119 | public function getOperatingSystem(): int |
||
132 | |||
133 | /** |
||
134 | * Locate command location. |
||
135 | * |
||
136 | * @param string $command |
||
137 | * |
||
138 | * @return string|null |
||
139 | */ |
||
140 | public function locateCommand($command): ?string |
||
166 | |||
167 | /** |
||
168 | * Check a function exists. |
||
169 | * |
||
170 | * @param string $function |
||
171 | * |
||
172 | * @return bool |
||
173 | */ |
||
174 | public function checkFunctionExists($function): bool |
||
178 | } |
||
179 |
If you suppress an error, we recommend checking for the error condition explicitly: