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