| Conditions | 3 |
| Paths | 3 |
| Total Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function validate() |
||
| 17 | { |
||
| 18 | $repository = new UserRepository(); |
||
| 19 | $existingUser = $repository->fetchUserModelByEmail($this->user->getEmail()); |
||
| 20 | if ($existingUser) { |
||
| 21 | if ($this->user->getId() !== $existingUser->getId()) { |
||
| 22 | throw new UserSpecificationException("Email {$existingUser->getEmail()} already exists in the system."); |
||
| 23 | } |
||
| 24 | } |
||
| 25 | } |
||
| 26 | } |
||
| 27 |
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: