| 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 |
|
| 21 |
|
| 22 |
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed |
| 23 |
{ |
| 24 |
|
| 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 |
|
| 41 |
|
| 42 |
public function getSupportedTypes(?string $format): array |
| 43 |
{ |
| 44 |
return [ |
| 45 |
AttestationStatement::class => true, |
| 46 |
]; |
| 47 |
} |
| 48 |
} |