| Conditions | 7 |
| Paths | 6 |
| Total Lines | 35 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function getFiles($path) |
||
| 19 | { |
||
| 20 | $process = new Process(sprintf('unrar 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 (trim($line) !== '' && strlen(str_replace([' ', '-'], '', $line)) === 0) { |
||
| 32 | if ($inFiles === false) { |
||
| 33 | $colSize = $this->getColSize($line); |
||
| 34 | } |
||
| 35 | $inFiles = !$inFiles; |
||
| 36 | |||
| 37 | continue; |
||
| 38 | } |
||
| 39 | |||
| 40 | if ($inFiles === false) { |
||
| 41 | continue; |
||
| 42 | } |
||
| 43 | |||
| 44 | $files[] = (new File()) |
||
| 45 | ->setUnpackedSize((int) trim((substr($line, $colSize['length'], $colSize['date'])))) |
||
| 46 | ->setPath(trim((substr($line, $colSize['name'])))) |
||
| 47 | ; |
||
| 48 | |||
| 49 | } |
||
| 50 | |||
| 51 | return $files; |
||
| 52 | } |
||
| 53 | |||
| 74 | } |