- md5
- 0069416e760c7501f25207c79ab875a7
- sha1
- 72f948e6b4becb145f78af570a68c7a425159b1a
- sha256
- 010bc59f644031f4c677511b57612aaafe50c22b67d91ead6b65c3c2541a5c7b
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
<?php
declare(strict_types=1);
namespace Jose\Component\Checker;
use InvalidArgumentException;
/**
* @see \Jose\Tests\Component\Checker\HeaderCheckerManagerFactoryTest
*/
class HeaderCheckerManagerFactory
{
/**
* @var HeaderChecker[]
*/
private array $checkers = [];
/**
* @var TokenTypeSupport[]
*/
private array $tokenTypes = [];
/**
* This method creates a Header Checker Manager and populate it with the header parameter checkers found based on
* the alias. If the alias is not supported, an InvalidArgumentException is thrown.
*
* @param string[] $aliases
*/
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);
}
/**
* This method adds a header parameter checker to this factory. The checker is uniquely identified by an alias. This
* allows the same header parameter checker to be added twice (or more) using several configuration options.
*/
public function add(string $alias, HeaderChecker $checker): void
{
$this->checkers[$alias] = $checker;
}
/**
* This method adds a token type support to this factory.
*/
public function addTokenTypeSupport(TokenTypeSupport $tokenType): void
{
$this->tokenTypes[] = $tokenType;
}
/**
* Returns all header parameter checker aliases supported by this factory.
*
* @return string[]
*/
public function aliases(): array
{
return array_keys($this->checkers);
}
/**
* Returns all header parameter checkers supported by this factory.
*
* @return HeaderChecker[]
*/
public function all(): array
{
return $this->checkers;
}
}
The same content is in 135 releases, Joomla 5.1.0-beta1 to 6.2.1. See them all, or every version of this file.