Passed
Pull Request — master (#41)
by Thomas
03:07
created

NotValid   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 35
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getPrevious() 0 4 1
1
<?php
2
3
namespace ORM\Dbal\Error;
4
5
use ORM\Dbal\Column;
6
use ORM\Dbal\Error;
7
8
class NotValid extends Error
9
{
10
    const ERROR_CODE = 'NOT_VALID';
11
12
    /** @var string */
13
    protected $message = 'Value not valid for %column% (Caused by: %previous%)';
14
15
    /** @var Error */
16
    protected $previous;
17
18
    /**
19
     * NotValid constructor
20
     *
21
     * @param Column $column The column that got a not valid error
22
     * @param Error  $previous The error from validate
23
     */
24 3
    public function __construct(Column $column, Error $previous)
25
    {
26 3
        parent::__construct();
27
28 3
        $this->previous = $previous;
29 3
        $this->params['column'] = $column->name;
30 3
        $this->params['previous'] = $previous->getMessage();
31 3
    }
32
33
    /**
34
     * Get the error that caused this error
35
     *
36
     * @return Error
37
     */
38 1
    public function getPrevious()
39
    {
40 1
        return $this->previous;
41
    }
42
}
43