public function userHasRole(AccountInterface $account, Site $site = null, $role = null)
    {
        if (null === $site && null === $role) {
          return (bool)count($this->getUserRoleCacheValue($account));
        }

        if (null === $site) {
            foreach ($this->getUserRoleCacheValue($account) as $grant) {
                if ($grant->getRole() === (int)$role) {
                    return true;
                }
            }
            return false;
        }

        if (null === $role) {
            $grant = $this->getUserRoleCacheValue($account, $site);
            return ($grant instanceof SiteAccessRecord) && ($grant->getRole() !== Access::ROLE_NONE);
        }

        if ($grant = $this->getUserRoleCacheValue($account, $site)) {
            return $grant->getRole() === (int)$role;
        }

        return false;
    }
public function userHasRole(AccountInterface $account, Site $site = null, $role = null)
    {
        if (null === $site && null === $role) {
          return (bool)count($this->getUserRoleCacheValue($account));
        }

        if (null === $site) {
            foreach ($this->getUserRoleCacheValue($account) as $grant) {
                if ($grant->getRole() === (int)$role) {
                    return true;
                }
            }
            return false;
        }

        if (null === $role) {
            $grant = $this->getUserRoleCacheValue($account, $site);
            return ($grant instanceof SiteAccessRecord) && ($grant->getRole() !== Access::ROLE_NONE);
        }

        if ($grant = $this->getUserRoleCacheValue($account, $site)) {
            return $grant->getRole() === (int)$role;
        }

        return false;
    }
public function userHasRole ( AccountInterface $ account , Site $ site = null , $ role = null ) { if ( null === $ site && null === $ role ) { return ( bool ) count ( $ this -> getUserRoleCacheValue ( $ account ) ) ; } if ( null === $ site ) { foreach ( $ this -> getUserRoleCacheValue ( $ account ) as $ grant ) { if ( $ grant -> getRole ( ) === ( int ) $ role ) { return true ; } } return false ; } if ( null === $ role ) { $ grant = $ this -> getUserRoleCacheValue ( $ account , $ site ) ; return ( $ grant instanceof SiteAccessRecord ) && ( $ grant -> getRole ( ) !== Access :: ROLE_NONE ) ; } if ( $ grant = $ this -> getUserRoleCacheValue ( $ account , $ site ) ) { return $ grant -> getRole ( ) === ( int ) $ role ; } return false ; }
Has the user the given role for the given site.

If no site is provided, informs if the user has the given relative role
for any site.
If no role is provided, informs if the user has any relative role.

@param AccountInterface $account
@param Site $site
@param int $role

@return boolean
Has the user the given role for the given site .