Conditions | 5 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public function __invoke(UserEntityInterface $user): array |
||
20 | { |
||
21 | $errors = []; |
||
22 | |||
23 | /** @var UserRepositoryInterface $userRepository */ |
||
24 | $userRepository = $this->container->get(UserRepositoryInterface::class); |
||
25 | $userExists = $userRepository->findByEmail($user->getEmail()); |
||
26 | if ($userExists && (!$user->getId() || ($user->getId() !== $userExists->getId()))) { |
||
27 | $errors[1300] = 'Email is already in user'; |
||
28 | } |
||
29 | |||
30 | if (empty($user->getPassword())) { |
||
31 | $errors[1301] = 'Password is empty'; |
||
32 | } |
||
33 | |||
34 | return $errors; |
||
35 | } |
||
36 | } |
||
37 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: