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