Conditions | 5 |
Paths | 5 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
32 | 5 | public function validate($user, Constraint $constraint): void |
|
33 | { |
||
34 | 5 | if (!$user instanceof AbstractUser) { |
|
35 | 1 | throw new UnexpectedTypeException($user, AbstractUser::class); |
|
36 | } |
||
37 | |||
38 | 4 | if (!$user->getNewEmailAddress()) { |
|
39 | 1 | return; |
|
40 | } |
||
41 | |||
42 | 3 | if ($user->getNewEmailAddress() === $user->getEmailAddress()) { |
|
43 | 1 | $this->context->buildViolation($constraint->differentMessage) |
|
44 | 1 | ->addViolation(); |
|
45 | |||
46 | 1 | return; |
|
47 | } |
||
48 | |||
49 | 2 | if ($this->userRepository->findOneBy(['email_address' => $user->getNewEmailAddress()])) { |
|
50 | 1 | $this->context->buildViolation($constraint->uniqueMessage) |
|
51 | 1 | ->addViolation(); |
|
52 | |||
53 | 1 | return; |
|
54 | } |
||
57 |