| Conditions | 7 |
| Paths | 8 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | public function __invoke(UserEntityInterface $user): array |
||
| 26 | { |
||
| 27 | $errors = []; |
||
| 28 | |||
| 29 | if (empty($user->getEmail())) { |
||
| 30 | $errors[1302] = 'Email is empty'; |
||
| 31 | } elseif (strlen($user->getEmail()) > 255) { |
||
| 32 | $errors[1303] = 'Email is too long'; |
||
| 33 | } else { |
||
| 34 | /** @var UserRepositoryInterface $userRepository */ |
||
| 35 | $userRepository = $this->container->get(UserRepositoryInterface::class); |
||
| 36 | $userExists = $userRepository->findByEmail($user->getEmail()); |
||
| 37 | if ($userExists && (!$user->getId() || ($user->getId() !== $userExists->getId()))) { |
||
| 38 | $errors[1300] = 'Email is already in use'; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | if (empty($user->getPassword())) { |
||
| 43 | $errors[1301] = 'Password is empty'; |
||
| 44 | } |
||
| 45 | |||
| 46 | return $errors; |
||
| 47 | } |
||
| 48 | } |
||
| 49 |