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