Conditions | 8 |
Paths | 6 |
Total Lines | 20 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 8.0231 |
Changes | 0 |
1 | <?php |
||
45 | 2 | public function parse(string $filename) |
|
46 | { |
||
47 | 2 | if ($this->checkFile($filename) |
|
48 | 2 | || ($handle = fopen(('.gz' == substr($filename, -3) ? 'compress.zlib://' : '').$filename, 'r')) === false) { |
|
49 | throw new \Exception('A problem occured with file `'.$filename.'`'); |
||
50 | } |
||
51 | |||
52 | 2 | $logs = []; |
|
53 | 2 | $lineCounter = 1; |
|
54 | 2 | while (!feof($handle)) { |
|
55 | 2 | $line = fgets($handle); |
|
56 | 2 | $line = $line ? $this->parser->parse($line) : null; |
|
57 | 2 | if ($line && $this->filter($line)) { |
|
58 | 2 | $logs[$lineCounter] = $line; |
|
59 | } |
||
60 | 2 | ++$lineCounter; |
|
61 | } |
||
62 | 2 | fclose($handle); |
|
63 | |||
64 | 2 | return $logs; |
|
65 | } |
||
67 |