Passed
Push — master ( f56605...d778ec )
by Smoren
02:21
created

CheckError::equalTo()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 3
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Smoren\Validator\Exceptions;
6
7
class CheckError extends \DomainException
8
{
9
    /**
10
     * @var string
11
     */
12
    protected string $name;
13
    /**
14
     * @var mixed
15
     */
16
    protected $value;
17
    /**
18
     * @var array<string, mixed>
19
     */
20
    protected array $params;
21
22
    /**
23
     * @param string $name
24
     * @param mixed $value
25
     * @param array<string, mixed> $params
26
     */
27 160
    public function __construct(string $name, $value, array $params)
28
    {
29 160
        parent::__construct('Check error');
30 160
        $this->name = $name;
31 160
        $this->value = $value;
32 160
        $this->params = $params;
33
    }
34
35
    /**
36
     * @return string
37
     */
38 160
    public function getName(): string
39
    {
40 160
        return $this->name;
41
    }
42
43
    /**
44
     * @return mixed
45
     */
46 1
    public function getValue()
47
    {
48 1
        return $this->value;
49
    }
50
51
    /**
52
     * @return array<string, mixed>
53
     */
54 160
    public function getParams(): array
55
    {
56 160
        return $this->params;
57
    }
58
59
    /**
60
     * @param CheckError $e
61
     *
62
     * @return bool
63
     */
64 2
    public function equalTo(CheckError $e): bool
65
    {
66 2
        return $this->name === $e->name
67 2
            && $this->value === $e->value
68 2
            && $this->params === $e->params;
69
    }
70
}
71