| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Webauthn\Denormalizer; |
| 6 |
|
| 7 |
use function array_key_exists; |
| 8 |
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; |
| 9 |
use Webauthn\MetadataService\Statement\ExtensionDescriptor; |
| 10 |
|
| 11 |
final class ExtensionDescriptorDenormalizer implements DenormalizerInterface |
| 12 |
{ |
| 13 |
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed |
| 14 |
{ |
| 15 |
|
| 16 |
if (array_key_exists('fail_if_unknown', $data)) { |
| 17 |
$data['failIfUnknown'] = $data['fail_if_unknown']; |
| 18 |
unset($data['fail_if_unknown']); |
| 19 |
} |
| 20 |
|
| 21 |
return ExtensionDescriptor::create(...$data); |
| 22 |
} |
| 23 |
|
| 24 |
public function supportsDenormalization( |
| 25 |
mixed $data, |
| 26 |
string $type, |
| 27 |
?string $format = null, |
| 28 |
array $context = [] |
| 29 |
): bool { |
| 30 |
return $type === ExtensionDescriptor::class; |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public function getSupportedTypes(?string $format): array |
| 37 |
{ |
| 38 |
return [ |
| 39 |
ExtensionDescriptor::class => true, |
| 40 |
]; |
| 41 |
} |
| 42 |
} |