AbstractParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrorMessage() 0 1 1
A __construct() 0 4 1
A throw() 0 4 1
1
<?php
2
namespace MetaHydrator\Parser;
3
4
use MetaHydrator\Exception\ParsingException;
5
6
/**
7
 * An abstract validator with configurable error message.
8
 *
9
 * Class AbstractParser
10
 * @package MetaHydrator\Parser
11
 */
12
abstract class AbstractParser implements ParserInterface
13
{
14
    /** @var mixed */
15
    private $errorMessage;
16
    /** @return mixed */
17
    public function getErrorMessage() { return $this->errorMessage; }
18
19
    /**
20
     * AbstractValidator constructor.
21
     * @param mixed $errorMessage
22
     */
23
    public function __construct($errorMessage = "")
24
    {
25
        $this->errorMessage = $errorMessage;
26
    }
27
28
    /**
29
     * @throws ParsingException
30
     */
31
    protected function throw()
32
    {
33
        throw new ParsingException($this->errorMessage);
34
    }
35
}
36