ValidationError   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 66
ccs 14
cts 14
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getRule() 0 3 1
A getMessage() 0 3 1
A getWeight() 0 3 1
A getPassword() 0 3 1
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