<?php
 declare(strict_types=1); namespace Jose\Component\Checker; use InvalidArgumentException; use function sprintf; class HeaderCheckerManagerFactory { private array $checkers = []; private array $tokenTypes = []; public function create(array $aliases): HeaderCheckerManager { $checkers = []; foreach ($aliases as $alias) { if (! isset($this->checkers[$alias])) { throw new InvalidArgumentException(sprintf( 'The header checker with the alias "%s" is not supported.', $alias )); } $checkers[] = $this->checkers[$alias]; } return new HeaderCheckerManager($checkers, $this->tokenTypes); } public function add(string $alias, HeaderChecker $checker): void { $this->checkers[$alias] = $checker; } public function addTokenTypeSupport(TokenTypeSupport $tokenType): void { $this->tokenTypes[] = $tokenType; } public function aliases(): array { return array_keys($this->checkers); } public function all(): array { return $this->checkers; } } 