ValidationError::getRule()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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