algorithms[$alias] = $algorithm; return $this; } /** * Returns the list of aliases. * * @return string[] */ public function aliases(): array { return \array_keys($this->algorithms); } /** * Returns all algorithms supported by this factory. * This is an associative array. Keys are the aliases of the algorithms. * * @return Algorithm[] */ public function all(): array { return $this->algorithms; } /** * Create an algorithm manager using the given aliases. * * @param string[] $aliases */ public function create(array $aliases): AlgorithmManager { $algorithms = []; foreach ($aliases as $alias) { if (\array_key_exists($alias, $this->algorithms)) { $algorithms[] = $this->algorithms[$alias]; } else { throw new \InvalidArgumentException(\sprintf('The algorithm with the alias "%s" is not supported.', $alias)); } } return AlgorithmManager::create($algorithms); } }