Total Complexity | 5 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | class UserNormalizer implements NormalizerInterface, NormalizerAwareInterface |
||
16 | { |
||
17 | use NormalizerAwareTrait; |
||
18 | |||
19 | private const ALREADY_CALLED = 'USER_NORMALIZER_ALREADY_CALLED'; |
||
20 | |||
21 | public function __construct( |
||
22 | private readonly NameConvention $nameConvention, |
||
23 | ) {} |
||
24 | |||
25 | public function normalize($object, ?string $format = null, array $context = []): array |
||
26 | { |
||
27 | $context[self::ALREADY_CALLED] = true; |
||
28 | |||
29 | $data = $this->normalizer->normalize($object, $format, $context); |
||
30 | |||
31 | $data['fullName'] = $this->nameConvention->getPersonName($object); |
||
32 | |||
33 | return $data; |
||
34 | } |
||
35 | |||
36 | public function supportsNormalization($data, ?string $format = null, array $context = []): bool |
||
43 | } |
||
44 | |||
45 | public function getSupportedTypes(?string $format): array |
||
48 | } |
||
49 | } |
||
50 |