authorizers = $authorizers; } /** * Adds a BasicAuthorizerInterface to the chain of authorizers. * @param BasicAuthorizerInterface $authorizer * @return CompoundAuthorizer */ public function addAuthorizer( BasicAuthorizerInterface $authorizer ): CompoundAuthorizer { $this->authorizers[] = $authorizer; return $this; } /** * Checks all registered authorizers and returns the first encountered error. * @param RequestInterface $request * @param Handler $handler * @return string|null */ public function authorize( RequestInterface $request, Handler $handler ) { foreach ( $this->authorizers as $authorizer ) { $result = $authorizer->authorize( $request, $handler ); if ( $result ) { return $result; } } return null; } }