| 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\MetadataService\Statement\VerificationMethodANDCombinations; |
| 12 |
use Webauthn\MetadataService\Statement\VerificationMethodDescriptor; |
| 13 |
|
| 14 |
final class VerificationMethodANDCombinationsDenormalizer implements NormalizerInterface, NormalizerAwareInterface |
| 15 |
{ |
| 16 |
use NormalizerAwareTrait; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
public function getSupportedTypes(?string $format): array |
| 22 |
{ |
| 23 |
return [ |
| 24 |
VerificationMethodANDCombinations::class => true, |
| 25 |
]; |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public function normalize(mixed $data, ?string $format = null, array $context = []): array |
| 32 |
{ |
| 33 |
assert($data instanceof VerificationMethodANDCombinations); |
| 34 |
|
| 35 |
|
| 36 |
return array_map( |
| 37 |
fn (VerificationMethodDescriptor $verificationMethod) => $this->normalizer->normalize( |
| 38 |
$verificationMethod, |
| 39 |
$format, |
| 40 |
$context |
| 41 |
), |
| 42 |
$data->verificationMethods |
| 43 |
); |
| 44 |
} |
| 45 |
|
| 46 |
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool |
| 47 |
{ |
| 48 |
return $data instanceof VerificationMethodANDCombinations; |
| 49 |
} |
| 50 |
} |