src/Controller/Component/AuthorizationComponent.php
protected function getIdentity(ServerRequestInterface $request)
    {
        $identityAttribute = $this->getConfig('identityAttribute');
        $identity = $request->getAttribute($identityAttribute);
        if ($identity === null) {
            return $identity;
        }
        if (!$identity instanceof IdentityInterface) {
            $type = is_object($identity) ? get_class($identity) : gettype($identity);
            throw new InvalidArgumentException(sprintf(
                'Expected that `%s` would be an instance of %s, but got %s',
                $identityAttribute,
                IdentityInterface::class,
                $type
            ));
        }

        return $identity;
    }
protected function getIdentity(ServerRequestInterface $request)
    {
        $identityAttribute = $this->getConfig('identityAttribute');
        $identity = $request->getAttribute($identityAttribute);
        if ($identity === null) {
            return $identity;
        }
        if (!$identity instanceof IdentityInterface) {
            $type = is_object($identity) ? get_class($identity) : gettype($identity);
            throw new InvalidArgumentException(sprintf(
                'Expected that `%s` would be an instance of %s, but got %s',
                $identityAttribute,
                IdentityInterface::class,
                $type
            ));
        }

        return $identity;
    }
protected function getIdentity ( ServerRequestInterface $ request ) { $ identityAttribute = $ this -> getConfig ( 'identityAttribute' ) ; $ identity = $ request -> getAttribute ( $ identityAttribute ) ; if ( $ identity === null ) { return $ identity ; } if ( ! $ identity instanceof IdentityInterface ) { $ type = is_object ( $ identity ) ? get_class ( $ identity ) : gettype ( $ identity ) ; throw new InvalidArgumentException ( sprintf ( 'Expected that `%s` would be an instance of %s, but got %s' , $ identityAttribute , IdentityInterface :: class , $ type ) ) ; } return $ identity ; }
Get the identity from a request.

@param \Psr\Http\Message\ServerRequestInterface $request The request
@return \Authorization\IdentityInterface|null
@throws \Authorization\Exception\MissingIdentityException When identity is not present in a request.
@throws \InvalidArgumentException When invalid identity encountered.
Get the identity from a request .