Debian Codegraph @

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

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Webauthn\Denormalizer;
6
7 use const JSON_THROW_ON_ERROR;
8 use JsonException;
9 use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
10 use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
11 use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
12 use Webauthn\CollectedClientData;
13
14 final class CollectedClientDataDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface
15 {
16 use DenormalizerAwareTrait;
17
18 /**
19 * @throws JsonException
20 */
21 public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
22 {
23 /** @var string $data */
24 /** @var array<string, mixed> $decoded */
25 $decoded = json_decode($data, true, flags: JSON_THROW_ON_ERROR);
26
27 return CollectedClientData::create($data, $decoded);
28 }
29
30 public function supportsDenormalization(
31 mixed $data,
32 string $type,
33 ?string $format = null,
34 array $context = []
35 ): bool {
36 return $type === CollectedClientData::class;
37 }
38
39 /**
40 * @return array<class-string, bool>
41 */
42 public function getSupportedTypes(?string $format): array
43 {
44 return [
45 CollectedClientData::class => true,
46 ];
47 }
48 }