Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
42.86% covered (danger)
42.86%
3 / 7
66.67% covered (warning)
66.67%
6 / 9
66.67% covered (warning)
66.67%
4 / 6
75.00% covered (warning)
75.00%
3 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
RetrieveIdentityInfoAdapter
42.86% covered (danger)
42.86%
3 / 7
66.67% covered (warning)
66.67%
6 / 9
66.67% covered (warning)
66.67%
4 / 6
75.00% covered (warning)
75.00%
3 / 4
7.33
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 map
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 getIdentityInfoFromId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getIdentityInfoFromUserId
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace App\Notification\Application\Adapter;
4
5use App\Notification\Application\Port\Driven\RetrieveIdentityDto;
6use App\Notification\Application\Port\Driven\RetrieveUserDto;
7use App\Notification\Domain\Model\IdentityInfo;
8use App\Notification\Domain\Port\Driven\RetrieveIdentityInfo;
9use MyLegoCollection\SharedContracts\Dto\IdentityDto;
10
11/**
12 * @author Wilhelm Zwertvaegher
13 */
14readonly class RetrieveIdentityInfoAdapter implements RetrieveIdentityInfo
15{
16
17    public function __construct(
18        private RetrieveIdentityDto $retrieveIdentityDto,
19        private RetrieveUserDto $retrieveUserDto
20    )
21    {
22    }
23
24    private function map(?IdentityDto $identityDto): ?IdentityInfo
25    {
26        return null === $identityDto ? null : new IdentityInfo($identityDto->getId(), $identityDto->getEmail(), $identityDto->getUsername());
27    }
28
29    public function getIdentityInfoFromId(string $identityId): ?IdentityInfo
30    {
31        return $this->map($this->retrieveIdentityDto->getIdentityDtoFromId($identityId));
32    }
33
34    public function getIdentityInfoFromUserId(string $userId): ?IdentityInfo
35    {
36        $userDto = $this->retrieveUserDto->getUserDtoFromId($userId);
37        if (null === $userDto) {
38            return null;
39        }
40
41        return $this->getIdentityInfoFromId($userDto->getIdentityId());
42    }
43}