1 | <?php |
||
2 | declare(strict_types = 1); |
||
3 | /** |
||
4 | * /src/AutoMapper/ApiKey/RequestMapper.php |
||
5 | * |
||
6 | * @author TLe, Tarmo Leppänen <[email protected]> |
||
7 | */ |
||
8 | |||
9 | namespace App\AutoMapper\ApiKey; |
||
10 | |||
11 | use App\AutoMapper\RestRequestMapper; |
||
12 | use App\Entity\UserGroup; |
||
13 | use App\Resource\UserGroupResource; |
||
14 | use Throwable; |
||
15 | use function array_map; |
||
16 | |||
17 | /** |
||
18 | * Class RequestMapper |
||
19 | * |
||
20 | * @package App\AutoMapper |
||
21 | * @author TLe, Tarmo Leppänen <[email protected]> |
||
22 | */ |
||
23 | class RequestMapper extends RestRequestMapper |
||
24 | { |
||
25 | /** |
||
26 | * Properties to map to destination object. |
||
27 | * |
||
28 | * @var array<int, non-empty-string> |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
29 | */ |
||
30 | protected static array $properties = [ |
||
31 | 'description', |
||
32 | 'userGroups', |
||
33 | ]; |
||
34 | |||
35 | 88 | public function __construct( |
|
36 | private readonly UserGroupResource $userGroupResource, |
||
37 | ) { |
||
38 | 88 | } |
|
39 | |||
40 | /** |
||
41 | * @param array<int, string> $userGroups |
||
42 | * |
||
43 | * @return array<int, UserGroup> |
||
44 | * |
||
45 | * @throws Throwable |
||
46 | */ |
||
47 | 4 | protected function transformUserGroups(array $userGroups): array |
|
48 | { |
||
49 | 4 | return array_map( |
|
50 | 4 | fn (string $userGroupUuid): UserGroup => $this->userGroupResource->getReference($userGroupUuid), |
|
51 | 4 | $userGroups, |
|
52 | 4 | ); |
|
53 | } |
||
54 | } |
||
55 |