Total Complexity | 8 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 76.47% |
Changes | 0 |
1 | <?php |
||
5 | class LogParser extends \Kassner\LogParser\LogParser |
||
6 | { |
||
7 | protected $domain; |
||
8 | protected $type; |
||
9 | |||
10 | public function setDomain(string $domain) |
||
11 | { |
||
12 | $this->domain = $domain; |
||
13 | } |
||
14 | |||
15 | 2 | public function setType(string $type) |
|
16 | { |
||
17 | 2 | $this->type = $type; |
|
18 | 2 | } |
|
19 | |||
20 | 2 | public function parse($line) |
|
21 | { |
||
22 | 2 | if (!preg_match($this->pcreFormat, $line, $matches)) { |
|
23 | throw new \Kassner\LogParser\FormatException($line); |
||
24 | } |
||
25 | |||
26 | 2 | $entry = $this->createEntry(); |
|
27 | 2 | foreach (array_filter(array_keys($matches), 'is_string') as $key) { |
|
28 | 2 | $setter = 'set'.$key; |
|
29 | 2 | if (method_exists($entry, $setter)) { |
|
30 | 2 | $entry->$setter($matches[$key]); |
|
31 | } |
||
32 | } |
||
33 | |||
34 | 2 | return $entry; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return LogLine |
||
39 | */ |
||
40 | 2 | protected function createEntry() |
|
43 | } |
||
44 | } |
||
45 |