public function isMember(PrincipalInterface $principal)
    {

        // first see if there is a key with the member name
        $isMember = $this->members->exists($principal->getName());

        if ($isMember === false) {
            // check the AnybodyPrincipal & NobodyPrincipal special cases
            $isMember = ($principal instanceof AnybodyPrincipal);
            if ($isMember === false) {
                if ($principal instanceof NobodyPrincipal) {
                    return false;
                }
            }
        }

        if ($isMember === false) {
            // check any groups for membership
            foreach ($this->members as $group) {
                if ($group instanceof GroupInterface) {
                    $isMember = $group->isMember($principal);
                }
            }
        }

        return $isMember;
    }