Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
CustomPasswordValidator | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
validate | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace App\Domain\User\Validator\Constraints; |
4 | |
5 | use Rollerworks\Component\PasswordStrength\Validator\Constraints\PasswordRequirementsValidator; |
6 | use Symfony\Component\Validator\Constraint; |
7 | |
8 | class CustomPasswordValidator extends PasswordRequirementsValidator |
9 | { |
10 | private $minLength; |
11 | private $requireCaseDiff; |
12 | private $requireLetters; |
13 | private $requireNumbers; |
14 | private $requireSpecialCharacter; |
15 | |
16 | public function __construct( |
17 | $minLength, |
18 | $requireCaseDiff, |
19 | $requireLetters, |
20 | $requireNumbers, |
21 | $requireSpecialCharacter, |
22 | ) { |
23 | $this->minLength = $minLength; |
24 | $this->requireCaseDiff = $requireCaseDiff; |
25 | $this->requireLetters = $requireLetters; |
26 | $this->requireNumbers = $requireNumbers; |
27 | $this->requireSpecialCharacter = $requireSpecialCharacter; |
28 | } |
29 | |
30 | /** |
31 | * @param string|null $value |
32 | * @param CustomPassword $constraint |
33 | */ |
34 | public function validate($value, Constraint $constraint) |
35 | { |
36 | $constraint->minLength = $this->minLength; |
37 | $constraint->requireCaseDiff = filter_var($this->requireCaseDiff, FILTER_VALIDATE_BOOLEAN); |
38 | $constraint->requireLetters = filter_var($this->requireLetters, FILTER_VALIDATE_BOOLEAN); |
39 | $constraint->requireNumbers = filter_var($this->requireNumbers, FILTER_VALIDATE_BOOLEAN); |
40 | $constraint->requireSpecialCharacter = filter_var($this->requireSpecialCharacter, FILTER_VALIDATE_BOOLEAN); |
41 | |
42 | parent::validate($value, $constraint); |
43 | } |
44 | } |