| Total Complexity | 18 |
| Total Lines | 63 |
| Duplicated Lines | 0 % |
| Coverage | 90.32% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class LogsAnalyzer |
||
| 6 | { |
||
| 7 | protected $parser; |
||
| 8 | |||
| 9 | protected $filter; |
||
| 10 | |||
| 11 | protected $logs = []; |
||
| 12 | |||
| 13 | 3 | public function __construct(string $type, ?string $domain = null) |
|
| 21 | 3 | } |
|
| 22 | |||
| 23 | /** |
||
| 24 | * The function must return TRUE for line we want to keep / FALSE for line to ignore |
||
| 25 | */ |
||
| 26 | 3 | public function setFilter($filter) |
|
| 27 | { |
||
| 28 | 3 | $this->filter = $filter; |
|
| 29 | 3 | } |
|
| 30 | |||
| 31 | 3 | protected function checkFile(string $filename): bool |
|
| 32 | { |
||
| 33 | 3 | return ! file_exists($filename) || ! is_readable($filename); |
|
| 34 | } |
||
| 35 | |||
| 36 | 3 | protected function filter($line) |
|
| 37 | { |
||
| 38 | 3 | if ($this->filter) { |
|
| 39 | 3 | return call_user_func($this->filter, $line); |
|
| 40 | } |
||
| 41 | |||
| 42 | return true; |
||
| 43 | } |
||
| 44 | |||
| 45 | 3 | public function parse(string $filename): array |
|
| 62 | } |
||
| 63 | |||
| 64 | 3 | protected function record($line, $lineCounter) |
|
| 68 | } |
||
| 69 | 3 | } |
|
| 70 | } |
||
| 71 |