ErrorLogParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 10
Bugs 1 Features 2
Metric Value
wmc 2
c 10
b 1
f 2
lcom 0
cbo 2
dl 0
loc 28
rs 10
ccs 7
cts 7
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareParsedData() 0 9 1
A getPattern() 0 7 1
1
<?php
2
3
/*
4
 * (c) Mantas Varatiejus <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace MVar\Apache2LogParser;
11
12
/**
13
 * Apache 2.2 and older error log parser.
14
 */
15
class ErrorLogParser extends AbstractLineParser
0 ignored issues
show
Deprecated Code introduced by
The class MVar\Apache2LogParser\AbstractLineParser has been deprecated with message: Will be removed in 3.0. Use \MVar\LogParser\AbstractLineParser instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
16
{
17
    use TimeFormatTrait;
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 3
    protected function prepareParsedData(array $matches)
23
    {
24 3
        $result = parent::prepareParsedData($matches);
25
26
        // Convert time
27 3
        $result['time'] = $this->formatTime($result['time']);
28
29 3
        return $result;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 3
    protected function getPattern()
36
    {
37
        $pattern = '/\[(?<time>.+)\] \[(?<error_level>\w+)\]( \[client\ (?<client_ip>.+)])? ' .
38 3
            '(?<message>.+(?=, referer)|.+)(, referer: (?<referer>.+))?/';
39
40 3
        return $pattern;
41
    }
42
}
43