AppserverIo\Appserver\ServletEngine\Security\SimplePrincipal::equals PHP Method

equals() public method

Compare this SimplePrincipal's name against another Principal.
public equals ( AppserverIo\Psr\Security\PrincipalInterface $another ) : boolean
$another AppserverIo\Psr\Security\PrincipalInterface The other principal to compare to
return boolean TRUE if name equals $another->getName();
    public function equals(PrincipalInterface $another)
    {
        // query whether or not another principal has been passed
        if ($another instanceof PrincipalInterface) {
            $anotherName = $another->getName();
            $equals = false;
            if ($this->name == null) {
                $equals = $anotherName == null;
            } else {
                $equals = $this->name->equals($anotherName);
            }
            // return the flag if the both are equal
            return $equals;
        }
        // return FALSE if they are not equal
        return false;
    }