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