Conditions | 6 |
Paths | 6 |
Total Lines | 33 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | public function getFiles($path) |
||
19 | { |
||
20 | $process = new Process(sprintf('unzip -l "%s"', $path)); |
||
21 | $process->run(); |
||
22 | if (!$process->isSuccessful()) { |
||
23 | throw new \RuntimeException($process->getErrorOutput()); |
||
24 | } |
||
25 | |||
26 | $files = []; |
||
27 | $inFiles = false; |
||
28 | $colSize = null; |
||
29 | foreach (explode(PHP_EOL, trim($process->getOutput())) as $line) { |
||
30 | |||
31 | if (strlen(str_replace([' ', '-'], '', $line)) === 0) { |
||
32 | if ($inFiles === false) { |
||
33 | $colSize = $this->getColSize($line); |
||
34 | } |
||
35 | $inFiles = !$inFiles; |
||
36 | continue; |
||
37 | } |
||
38 | |||
39 | if ($inFiles === false) { |
||
40 | continue; |
||
41 | } |
||
42 | |||
43 | $files[] = (new File()) |
||
44 | ->setUnpackedSize((int) trim((substr($line, $colSize['length'], $colSize['date'])))) |
||
45 | ->setPath(trim((substr($line, $colSize['name'])))) |
||
46 | ; |
||
47 | } |
||
48 | |||
49 | return $files; |
||
50 | } |
||
51 | |||
70 | } |