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

NotValid::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
crap 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