Debian Codegraph @

lib/3rdParty/composer/web-auth/webauthn-lib/src/Denormalizer/SignalCurrentUserDetailsDenormalizer.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Webauthn\Denormalizer;
6
7 use function assert;
8 use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
9 use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
10 use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
11 use Webauthn\Signal\CurrentUserDetails;
12
13 class SignalCurrentUserDetailsDenormalizer implements NormalizerInterface, NormalizerAwareInterface
14 {
15 use NormalizerAwareTrait;
16
17 /**
18 * @return array<class-string, bool>
19 */
20 public function getSupportedTypes(?string $format): array
21 {
22 return [
23 CurrentUserDetails::class => true,
24 ];
25 }
26
27 /**
28 * @return array<string, mixed>
29 */
30 public function normalize(mixed $data, ?string $format = null, array $context = []): array
31 {
32 assert($data instanceof CurrentUserDetails);
33
34 /** @var array<string, mixed> $normalized_rp */
35 $normalized_rp = $this->normalizer->normalize($data->rp, $format, $context);
36
37 /** @var array<string, mixed> $normalized_user */
38 $normalized_user = $this->normalizer->normalize($data->user, $format, $context);
39
40 return [
41 'rpId' => $normalized_rp['id'],
42 'userId' => $normalized_user['id'],
43 'name' => $normalized_user['name'],
44 'displayName' => $normalized_user['displayName'],
45 ];
46 }
47
48 public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
49 {
50 return $data instanceof CurrentUserDetails;
51 }
52 }