Debian Codegraph @

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

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Webauthn\Denormalizer;
6
7 use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
8 use Webauthn\AttestationStatement\AttestationStatement;
9 use Webauthn\AttestationStatement\AttestationStatementSupportManager;
10 use Webauthn\Exception\InvalidDataException;
11
12 final readonly class AttestationStatementDenormalizer implements DenormalizerInterface
13 {
14 public function __construct(
15 private AttestationStatementSupportManager $attestationStatementSupportManager
16 ) {
17 }
18
19 /**
20 * @throws InvalidDataException
21 */
22 public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
23 {
24 /** @var array{fmt: string, attStmt: array<string, mixed>, authData: string} $data */
25 $attestationStatementSupport = $this->attestationStatementSupportManager->get($data['fmt']);
26
27 return $attestationStatementSupport->load($data);
28 }
29
30 public function supportsDenormalization(
31 mixed $data,
32 string $type,
33 ?string $format = null,
34 array $context = []
35 ): bool {
36 return $type === AttestationStatement::class;
37 }
38
39 /**
40 * @return array<class-string, bool>
41 */
42 public function getSupportedTypes(?string $format): array
43 {
44 return [
45 AttestationStatement::class => true,
46 ];
47 }
48 }