| Total Complexity | 5 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 61.53% |
| Changes | 0 | ||
| 1 | <?php declare(strict_types = 1); |
||
| 9 | final class PersonRepository extends EntityRepository |
||
| 10 | { |
||
| 11 | const EMAIL_FIELD = 'email'; |
||
| 12 | |||
| 13 | 1 | public function ofId(string $id): Person |
|
| 14 | { |
||
| 15 | 1 | $person = $this->find($id); |
|
| 16 | |||
| 17 | 1 | if (!$person instanceof Person) { |
|
| 18 | throw new ResourceNotFoundException(); |
||
| 19 | } |
||
| 20 | |||
| 21 | 1 | return $person; |
|
| 22 | } |
||
| 23 | |||
| 24 | 1 | public function ofUsername(string $username): Person |
|
| 25 | { |
||
| 26 | 1 | $person = $this->findOneBy([self::EMAIL_FIELD => $username]); |
|
| 27 | |||
| 28 | 1 | if (!$person instanceof Person) { |
|
| 29 | throw new ResourceNotFoundException(); |
||
| 30 | } |
||
| 31 | |||
| 32 | 1 | return $person; |
|
| 33 | } |
||
| 34 | |||
| 35 | public function save(Person $person): void |
||
| 39 | } |
||
| 40 | } |
||
| 41 |