1 | <?php |
||
13 | class File |
||
14 | { |
||
15 | /** |
||
16 | * @var ClientInterface |
||
17 | */ |
||
18 | private $guzzleClient; |
||
19 | |||
20 | /** |
||
21 | * @var Filesystem |
||
22 | */ |
||
23 | 27 | private $filesystem; |
|
24 | |||
25 | 27 | /** |
|
26 | 27 | * @var ZipArchive |
|
27 | 27 | */ |
|
28 | private $zipArchive; |
||
29 | |||
30 | public function __construct(ClientInterface $guzzleClient = null) |
||
36 | |||
37 | 2 | /** |
|
38 | * @param $source |
||
39 | 2 | * @param null|string $destination |
|
40 | 2 | * |
|
41 | 1 | * @throws NoFileDestinationException|FileNotCopiedException |
|
42 | * |
||
43 | 1 | * @return string |
|
44 | 1 | */ |
|
45 | 1 | public function copyFile($source, $destination = null) |
|
66 | |||
67 | /** |
||
68 | * @param string $file |
||
69 | 2 | * |
|
70 | * @return bool |
||
71 | 2 | */ |
|
72 | public function isHealthyZipFile($file) |
||
84 | |||
85 | 2 | /** |
|
86 | * @param string $url |
||
87 | 2 | * @param string $destination |
|
88 | 2 | * |
|
89 | 2 | * @throws CurlException |
|
90 | 1 | * @throws HttpStatusCodeException |
|
91 | * @throws \Exception |
||
92 | 1 | * |
|
93 | 1 | * @return string |
|
94 | 1 | */ |
|
95 | 1 | public function download($url, $destination) |
|
101 | 1 | ||
102 | /** |
||
103 | 1 | * @param string $file zipFile we want to open |
|
104 | * @param null|string $extractTo |
||
105 | * @param true|bool $delete |
||
106 | * |
||
107 | * @throws Exception |
||
108 | * |
||
109 | * @return array |
||
110 | */ |
||
111 | public function unZip($file, $extractTo = null, $delete = true) |
||
131 | |||
132 | /** |
||
133 | * @param string $file |
||
134 | * @return string[] |
||
135 | */ |
||
136 | public function readFileLinesIntoArray($file) |
||
140 | |||
141 | /** |
||
142 | * @param string[] $lines |
||
143 | * @param string $file |
||
144 | */ |
||
145 | public function writeLinesToFile($lines, $file) |
||
151 | } |
||
152 |
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.