, type?: string} $data */ return match (true) { array_key_exists('x5c', $data) && is_array($data['x5c']) => CertificateTrustPath::create($data['x5c']), $data === [], isset($data['type']) && $data['type'] === EmptyTrustPath::class => EmptyTrustPath::create(), default => throw new InvalidTrustPathException('Unsupported trust path type'), }; } public function supportsDenormalization( mixed $data, string $type, ?string $format = null, array $context = [] ): bool { return $type === TrustPath::class; } /** * @return array */ public function getSupportedTypes(?string $format): array { return [ TrustPath::class => true, ]; } /** * @return array */ public function normalize(mixed $data, ?string $format = null, array $context = []): array { assert($data instanceof TrustPath); return match (true) { $data instanceof CertificateTrustPath => [ 'x5c' => $data->certificates, ], $data instanceof EmptyTrustPath => [], default => throw new InvalidTrustPathException('Unsupported trust path type'), }; } public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { return $data instanceof TrustPath; } }