Total Complexity | 6 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
6 | class PasswordValidator |
||
7 | { |
||
8 | /** @var Validator[] $validators */ |
||
9 | private $validators = []; |
||
10 | |||
11 | public function __construct(iterable $validators = []) |
||
12 | { |
||
13 | foreach ($validators as $validator) { |
||
14 | $this->addValidator($validator); |
||
15 | } |
||
16 | } |
||
17 | |||
18 | /** |
||
19 | * Adds a validator to the current PasswordValidator instance |
||
20 | * |
||
21 | * @param Validator $validator |
||
22 | */ |
||
23 | public function addValidator(Validator $validator): void |
||
24 | { |
||
25 | $this->validators[] = $validator; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Gets an array of the currently applied Validators |
||
30 | * |
||
31 | * @return Validator[] |
||
32 | */ |
||
33 | public function getValidators(): array |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Validates the given password against the current rule set. |
||
40 | * |
||
41 | * @param string $password |
||
42 | * @return bool True if the password is valid |
||
43 | * @throws PasswordException If the password fails a validation attempt. |
||
44 | */ |
||
45 | public function validate(string $password): bool |
||
54 |