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