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

ConfirmPasswordValidator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 16 4
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