ErrorLogParser::getPattern()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 5
Bugs 0 Features 2
Metric Value
c 5
b 0
f 2
dl 0
loc 7
ccs 3
cts 3
cp 1
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
crap 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