1 | <?php |
||
14 | class File |
||
15 | { |
||
16 | /** |
||
17 | * @var ClientInterface |
||
18 | */ |
||
19 | private $guzzleClient; |
||
20 | |||
21 | /** |
||
22 | * @var Filesystem |
||
23 | 27 | */ |
|
24 | private $filesystem; |
||
25 | 27 | ||
26 | 27 | /** |
|
27 | 27 | * @var Finder |
|
28 | */ |
||
29 | private $finder; |
||
30 | |||
31 | /** |
||
32 | * @var ZipArchive |
||
33 | */ |
||
34 | private $zipArchive; |
||
35 | |||
36 | public function __construct(ClientInterface $guzzleClient, Filesystem $fileSystem, Finder $finder) |
||
43 | 1 | ||
44 | 1 | /** |
|
45 | 1 | * @param $source |
|
46 | 1 | * @param null|string $destination |
|
47 | 1 | * |
|
48 | 1 | * @throws NoFileDestinationException|FileNotCopiedException |
|
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | 1 | public function copyFile($source, $destination = null) |
|
73 | 2 | ||
74 | /** |
||
75 | * @param string $file |
||
76 | * |
||
77 | * @return bool |
||
78 | */ |
||
79 | public function isHealthyZipFile($file) |
||
91 | |||
92 | 1 | /** |
|
93 | 1 | * @param string $url |
|
94 | 1 | * @param string $destination |
|
95 | 1 | * |
|
96 | 1 | * @throws CurlException |
|
97 | 1 | * @throws HttpStatusCodeException |
|
98 | 1 | * @throws \Exception |
|
99 | 1 | * |
|
100 | 1 | * @return string |
|
101 | 1 | */ |
|
102 | public function download($url, $destination) |
||
108 | |||
109 | /** |
||
110 | * @param string $file zipFile we want to open |
||
111 | * @param null|string $extractTo |
||
112 | * @param true|bool $delete |
||
113 | * |
||
114 | * @throws Exception |
||
115 | * |
||
116 | * @return array |
||
117 | */ |
||
118 | public function unZip($file, $extractTo = null, $delete = true) |
||
138 | |||
139 | /** |
||
140 | * @param string $file |
||
141 | * @return string[] |
||
142 | */ |
||
143 | public function readFileLinesIntoArray($file) |
||
147 | |||
148 | /** |
||
149 | * @param string[] $lines |
||
150 | * @param string $file |
||
151 | */ |
||
152 | public function writeLinesToFile($lines, $file) |
||
158 | |||
159 | /** |
||
160 | * @param string|string[] $cache |
||
161 | */ |
||
162 | public function clearCache($cache) |
||
176 | |||
177 | /** |
||
178 | * @param string $file |
||
179 | */ |
||
180 | private function removeFile($file) |
||
184 | |||
185 | /** |
||
186 | * @param string[] $files |
||
187 | * @param string $target |
||
188 | */ |
||
189 | public function moveFirstFile(array $files, $target) |
||
193 | |||
194 | public function createDirIfNotExists($path) |
||
200 | } |
||
201 |
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.