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