Identity/SubjectIdentity.php
public static function fromObject($object)
    {
        try {
            if (!\is_object($object)) {
                throw new UnexpectedTypeException($object, 'object');
            }

            if ($object instanceof SubjectIdentityInterface) {
                return $object;
            }
            if ($object instanceof SubjectInterface) {
                return new self(ClassUtils::getClass($object), (string) $object->getSubjectIdentifier(), $object);
            }
            if (method_exists($object, 'getId')) {
                return new self(ClassUtils::getClass($object), (string) $object->getId(), $object);
            }
        } catch (InvalidArgumentException $e) {
            throw new InvalidSubjectIdentityException($e->getMessage(), 0, $e);
        }

        throw new InvalidSubjectIdentityException('The object must either implement the SubjectInterface, or have a method named "getId"');
    }
public static function fromObject($object)
    {
        try {
            if (!\is_object($object)) {
                throw new UnexpectedTypeException($object, 'object');
            }

            if ($object instanceof SubjectIdentityInterface) {
                return $object;
            }
            if ($object instanceof SubjectInterface) {
                return new self(ClassUtils::getClass($object), (string) $object->getSubjectIdentifier(), $object);
            }
            if (method_exists($object, 'getId')) {
                return new self(ClassUtils::getClass($object), (string) $object->getId(), $object);
            }
        } catch (InvalidArgumentException $e) {
            throw new InvalidSubjectIdentityException($e->getMessage(), 0, $e);
        }

        throw new InvalidSubjectIdentityException('The object must either implement the SubjectInterface, or have a method named "getId"');
    }
public static function fromObject ( $ object ) { try { if ( ! \ is_object ( $ object ) ) { throw new UnexpectedTypeException ( $ object , 'object' ) ; } if ( $ object instanceof SubjectIdentityInterface ) { return $ object ; } if ( $ object instanceof SubjectInterface ) { return new self ( ClassUtils :: getClass ( $ object ) , ( string ) $ object -> getSubjectIdentifier ( ) , $ object ) ; } if ( method_exists ( $ object , 'getId' ) ) { return new self ( ClassUtils :: getClass ( $ object ) , ( string ) $ object -> getId ( ) , $ object ) ; } } catch ( InvalidArgumentException $ e ) { throw new InvalidSubjectIdentityException ( $ e -> getMessage ( ) , 0 , $ e ) ; } throw new InvalidSubjectIdentityException ( 'The object must either implement the SubjectInterface, or have a method named "getId"' ) ; }
Creates a subject identity for the given object.

@param object $object The object

@throws InvalidSubjectIdentityException

@return SubjectIdentityInterface
Creates a subject identity for the given object .