AbstractLineParser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 4
c 4
b 0
f 1
lcom 0
cbo 3
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parseLine() 0 19 4
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
use MVar\Apache2LogParser\Exception\NoMatchesException;
13
use MVar\Apache2LogParser\Exception\ParserException;
14
15
/**
16
 * Abstract line parser.
17
 *
18
 * @deprecated Will be removed in 3.0. Use \MVar\LogParser\AbstractLineParser instead.
19
 */
20
abstract class AbstractLineParser extends \MVar\LogParser\AbstractLineParser implements LineParserInterface
0 ignored issues
show
Deprecated Code introduced by
The interface MVar\Apache2LogParser\LineParserInterface has been deprecated with message: Will be removed in 3.0. Use \MVar\LogParser\LineParserInterface 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...
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function parseLine($line)
26
    {
27
        if (!is_string($line)) {
28
            throw new ParserException('Parser argument must be a string.');
0 ignored issues
show
Deprecated Code introduced by
The class MVar\Apache2LogParser\Exception\ParserException has been deprecated with message: Will be removed in 3.0. Use \MVar\LogParser\Exception\ParserException 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...
29
        }
30
31
        $match = @preg_match($this->getPattern(), $line, $matches);
32
33
        if ($match === false) {
34
            $error = error_get_last();
35
            throw new ParserException("Matcher failure. Please check if given format is valid. ({$error["message"]})");
0 ignored issues
show
Deprecated Code introduced by
The class MVar\Apache2LogParser\Exception\ParserException has been deprecated with message: Will be removed in 3.0. Use \MVar\LogParser\Exception\ParserException 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...
36
        }
37
38
        if (!$match) {
39
            throw new NoMatchesException('Given line does not match predefined pattern.');
0 ignored issues
show
Deprecated Code introduced by
The class MVar\Apache2LogParser\Exception\NoMatchesException has been deprecated with message: Will be removed in 3.0. Use \MVar\LogParser\Exception\MatchException 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...
40
        }
41
42
        return $this->prepareParsedData($matches);
43
    }
44
}
45