Passed
Push — master ( f8d35a...cc8b44 )
by Magnar Ovedal
02:39
created

ValidationError::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 4
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stadly\PasswordPolice;
6
7
use Stadly\PasswordPolice\Rule\RuleInterface;
8
9
final class ValidationError
10
{
11
    /**
12
     * @var string Message describing why the password could not be validated.
13
     */
14
    private $message;
15
16
    /**
17
     * @var Password|string $password Password that could not be validated.
18
     */
19
    private $password;
20
21
    /**
22
     * @var RuleInterface Rule that the password is not in compliance with.
23
     */
24
    private $rule;
25
26
    /**
27
     * @var int Weight of violated constraint.
28
     */
29
    private $weight;
30
31
    /**
32
     * @param string $message Message describing why the password could not be validated.
33
     * @param Password|string $password Password that could not be validated.
34
     * @param RuleInterface $rule Rule that the password is not in compliance with.
35
     * @param int $weight Weight of violated constraint.
36
     */
37 1
    public function __construct(string $message, $password, RuleInterface $rule, int $weight)
38
    {
39 1
        $this->message = $message;
40 1
        $this->password = $password;
41 1
        $this->rule = $rule;
42 1
        $this->weight = $weight;
43 1
    }
44
45
    /**
46
     * @return string Message describing why the password could not be validated.
47
     */
48 1
    public function getMessage(): string
49
    {
50 1
        return $this->message;
51
    }
52
53
    /**
54
     * @return Password|string $password Password that could not be validated.
55
     */
56 1
    public function getPassword()
57
    {
58 1
        return $this->password;
59
    }
60
61
    /**
62
     * @return RuleInterface Rule that the password is not in compliance with.
63
     */
64 1
    public function getRule(): RuleInterface
65
    {
66 1
        return $this->rule;
67
    }
68
69
    /**
70
     * @return int Weight of violated constraint.
71
     */
72 1
    public function getWeight(): int
73
    {
74 1
        return $this->weight;
75
    }
76
}
77