Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
6 / 6 |
|
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| RetrieveIdentityDtoAdapter | |
100.00% |
3 / 3 |
|
100.00% |
6 / 6 |
|
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| map | |
100.00% |
1 / 1 |
|
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
| getIdentityDtoFromId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Auth\Infrastructure\Adapter; |
| 4 | |
| 5 | use App\Auth\Domain\Model\Identity; |
| 6 | use App\Auth\Domain\Port\Driven\IdentityRepository; |
| 7 | use App\Notification\Application\Port\Driven\RetrieveIdentityDto; |
| 8 | use App\Notification\Domain\Model\IdentityInfo; |
| 9 | use App\Shared\Domain\Model\EntityId; |
| 10 | use MyLegoCollection\SharedContracts\Dto\IdentityDto; |
| 11 | |
| 12 | /** |
| 13 | * @author Wilhelm Zwertvaegher |
| 14 | */ |
| 15 | readonly class RetrieveIdentityDtoAdapter implements RetrieveIdentityDto |
| 16 | { |
| 17 | public function __construct(private IdentityRepository $identityRepository) |
| 18 | { |
| 19 | } |
| 20 | |
| 21 | private function map(?Identity $identity): ?IdentityDto |
| 22 | { |
| 23 | return null === $identity ? null : new IdentityDto($identity->getId(), $identity->getEmail(), $identity->getUsername()); |
| 24 | } |
| 25 | |
| 26 | public function getIdentityDtoFromId(string $identityId): ?IdentityDto |
| 27 | { |
| 28 | return $this->map($this->identityRepository->findById(EntityId::fromString($identityId))); |
| 29 | } |
| 30 | } |