Completed
Push — master ( 577a52...db05bc )
by Valery
09:02
created

ConfirmPasswordValidator::validate()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 4
nc 3
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Validator;
6
7
use Symfony\Component\Validator\Constraint;
8
use Symfony\Component\Validator\ConstraintValidator;
9
10
final class ConfirmPasswordValidator extends ConstraintValidator
11
{
12
    public function validate($value, Constraint $constraint)
13
    {
14
        /* @var $constraint \App\Validator\ConfirmPassword */
15
16
        if (null === $value || '' === $value) {
17
            return;
18
        }
19
20
        $password = $this->context->getRoot()->get('password')->getData();
21
22
        if ($password !== $value) {
23
            $this->context->buildViolation($constraint->message)
24
                ->atPath('password_confirmation')
25
                ->addViolation();
26
        }
27
    }
28
}
29