src/Middleware/AuthorizationMiddleware.php
protected function buildIdentity(AuthorizationServiceInterface $service, $identity)
    {
        $class = $this->getConfig('identityDecorator');

        if (is_callable($class)) {
            $identity = $class($service, $identity);
        } else {
            if (!$identity instanceof IdentityInterface) {
                $identity = new $class($service, $identity);
            }
        }

        if (!$identity instanceof IdentityInterface) {
            throw new RuntimeException(sprintf(
                'Invalid identity returned by decorator. `%s` does not implement `%s`.',
                is_object($identity) ? get_class($identity) : gettype($identity),
                IdentityInterface::class
            ));
        }

        return $identity;
    }
protected function buildIdentity(AuthorizationServiceInterface $service, $identity)
    {
        $class = $this->getConfig('identityDecorator');

        if (is_callable($class)) {
            $identity = $class($service, $identity);
        } else {
            if (!$identity instanceof IdentityInterface) {
                $identity = new $class($service, $identity);
            }
        }

        if (!$identity instanceof IdentityInterface) {
            throw new RuntimeException(sprintf(
                'Invalid identity returned by decorator. `%s` does not implement `%s`.',
                is_object($identity) ? get_class($identity) : gettype($identity),
                IdentityInterface::class
            ));
        }

        return $identity;
    }
protected function buildIdentity ( AuthorizationServiceInterface $ service , $ identity ) { $ class = $ this -> getConfig ( 'identityDecorator' ) ; if ( is_callable ( $ class ) ) { $ identity = $ class ( $ service , $ identity ) ; } else { if ( ! $ identity instanceof IdentityInterface ) { $ identity = new $ class ( $ service , $ identity ) ; } } if ( ! $ identity instanceof IdentityInterface ) { throw new RuntimeException ( sprintf ( 'Invalid identity returned by decorator. `%s` does not implement `%s`.' , is_object ( $ identity ) ? get_class ( $ identity ) : gettype ( $ identity ) , IdentityInterface :: class ) ) ; } return $ identity ; }
Builds the identity object.

@param \Authorization\AuthorizationServiceInterface $service Authorization service.
@param \ArrayAccess|array $identity Identity data
@return \Authorization\IdentityInterface
Builds the identity object .