<?php
 declare(strict_types=1); namespace Jose\Component\Encryption\Serializer; use InvalidArgumentException; use function sprintf; final class JWESerializerManagerFactory { private array $serializers = []; public function create(array $names): JWESerializerManager { $serializers = []; foreach ($names as $name) { if (! isset($this->serializers[$name])) { throw new InvalidArgumentException(sprintf('Unsupported serializer "%s".', $name)); } $serializers[] = $this->serializers[$name]; } return new JWESerializerManager($serializers); } public function names(): array { return array_keys($this->serializers); } public function all(): array { return $this->serializers; } public function add(JWESerializer $serializer): void { $this->serializers[$serializer->name()] = $serializer; } } 