*/ private array $gates = []; /** * @param array $gates Pre-ordered gates (injected by ModuleAccessGatePass) */ public function __construct(array $gates = []) { foreach ($gates as $identifier => $gate) { $this->gates[$identifier] = $gate; } } public function has(string $identifier): bool { return isset($this->gates[$identifier]); } /** * @throws \InvalidArgumentException if gate does not exist */ public function get(string $identifier): ModuleAccessGateInterface { if (!$this->has($identifier)) { throw new \InvalidArgumentException( sprintf('Module access gate with identifier "%s" is not registered.', $identifier), 1774436666 ); } return $this->gates[$identifier]; } /** * @return array */ public function getAll(): array { return $this->gates; } }