src/Middleware/AuthenticationMiddleware.php
protected function getAuthenticationService($request, $response)
    {
        $subject = $this->subject;

        if ($subject instanceof AuthenticationServiceProviderInterface) {
            $subject = $this->subject->getAuthenticationService($request, $response);
        }

        if (!$subject instanceof AuthenticationServiceInterface) {
            $type = is_object($subject) ? get_class($subject) : gettype($subject);
            $message = sprintf('Service provided by a subject must be an instance of `%s`, `%s` given.', AuthenticationServiceInterface::class, $type);

            throw new RuntimeException($message);
        }

        return $subject;
    }
protected function getAuthenticationService($request, $response)
    {
        $subject = $this->subject;

        if ($subject instanceof AuthenticationServiceProviderInterface) {
            $subject = $this->subject->getAuthenticationService($request, $response);
        }

        if (!$subject instanceof AuthenticationServiceInterface) {
            $type = is_object($subject) ? get_class($subject) : gettype($subject);
            $message = sprintf('Service provided by a subject must be an instance of `%s`, `%s` given.', AuthenticationServiceInterface::class, $type);

            throw new RuntimeException($message);
        }

        return $subject;
    }
protected function getAuthenticationService ( $ request , $ response ) { $ subject = $ this -> subject ; if ( $ subject instanceof AuthenticationServiceProviderInterface ) { $ subject = $ this -> subject -> getAuthenticationService ( $ request , $ response ) ; } if ( ! $ subject instanceof AuthenticationServiceInterface ) { $ type = is_object ( $ subject ) ? get_class ( $ subject ) : gettype ( $ subject ) ; $ message = sprintf ( 'Service provided by a subject must be an instance of `%s`, `%s` given.' , AuthenticationServiceInterface :: class , $ type ) ; throw new RuntimeException ( $ message ) ; } return $ subject ; }
Returns AuthenticationServiceInterface instance.

@param \Psr\Http\Message\ServerRequestInterface $request Server request.
@param \Psr\Http\Message\ResponseInterface $response Response.
@return \Authentication\AuthenticationServiceInterface
@throws \RuntimeException When authentication method has not been defined.
Returns AuthenticationServiceInterface instance .