Check if the user has all roles.

@param int|string|array $role

@return bool
543828
public function hasAllRoles($role)
    {
        foreach ($this->getArrayFrom($role) as $role) {
            if (!$this->checkRole($role)) {
                return false;
            }
        }

        return true;
    }
667762
public function userHasRole(string $role): bool
    {
        $user = $this->getUser();
        
        if($user->hasRole($role))
            return true;
        
        if (null === $userRoles = $user->getRoles())
            return false;
        
        foreach ($userRoles as $userRole) {
            try {
                if(\in_array($role, $this->getRoles($userRole)))
                    return true;                
            } catch (UndefinedRoleException $e) {
                continue;
            }
        }
        
        return false;
    }
377223
public static function hasRole($roles)
    {
        $user = wp_get_current_user();

        if (is_string($roles)) {
            $roles = array($roles);
        }

        if (!array_intersect($roles, $user->roles)) {
            return false;
        }

        return true;
    }
388219
public function hasRole($role = "general")
	{
        $roleModel = new \erdiko\users\models\Role;
        $roleEntity = $roleModel->findByName($role);
        if (empty($roleEntity)) {
            throw  new \Exception("Error, role {$role} not found.");
        }
        $result = $this->_user->getRole() == $roleEntity->getId();

		return $result;
	}
905214
public function hasRole($role)
    {
        if ($this->user() === null) {
            return null;
        }

        return in_array($role, $this->roles, true);
    }
803589
public function all($role)
    {
        $roles = func_get_args();

        return $this->clipboard->checkRole($this->authority, $roles, 'and');
    }
123458
public function hasRole($role)
    {
        $roles = array_column($this->roles->toArray(), 'name');
        return array_search($role, $roles) > -1;
    }
450869
public function isAn($role)
    {
        $roles = func_get_args();

        $clipboard = $this->getClipboardInstance();

        return $clipboard->checkRole($this, $roles, 'or');
    }
963210
protected function checkRoles(array $roles)
    {
        $checkedRoles = array();
        foreach ($roles as $role) {
            if (true === is_string($role) && false === in_array($role, $checkedRoles)) {
                $checkedRoles[] = (string)$role;
            }
        }
        return $checkedRoles;
    }
320145
private function _checkRoles($roles)
    {
        if (!$roles) {
            return true;
        }

        foreach ($roles as $role) {
            if (Yii::$app->user->can($role)) {
                return true;
            }
        }

        return false;
    }
938098
public function hasRole($role)
    {
        foreach ($this->roles as $roleObj) {
            if($role == $roleObj->getRole()){
                return true;
            }
        }
        return false;
    }
61613
public function getAllPermissionsForRole($role)
    {
        /** @var EloquentRole $role */
        $role = $this->getRole($role);

        if ( ! $role) {
            return [];
        }

        $permissions = array_keys(array_filter($role->getPermissions()));
        sort($permissions);

        return $permissions;
    }
1318280
public function matchIdentityRoles(array $roles): bool
    {
        $identityRoles = $this->getIdentityRoles();
        // Too easy...
        if (empty($identityRoles)) {
            return false;
        }
        $roleNames = [];
        foreach ($roles as $role) {
            $roleNames[] = $role instanceof RoleInterface ? $role->getName() : (string)$role;
        }

        $identityRoleNames = [];
        foreach ($this->flattenRoles($identityRoles) as $role) {
            $identityRoleNames[] = $role->getName();
        }

        return count(array_intersect($roleNames, $identityRoleNames)) > 0;
    }
1005095
public function handle($role)
    {
        if ($this->auth->check()) {
            return $this->auth->user()->isRole($role);
        } else {
            if ($role === 'guest') {
                return true;
            }
        }

        return false;
    }
22051
protected function getRole($role)
	{
		if (!isset($this->user))
			return false;

		if (isset($this->user->role))
			return $this->user->role->hasPermission($role);

		return false;
	}
748480
public static function roleGrant($role) {
		// add roles
		if (!empty($role)) {
			// initialize roles array
			if (!isset($_SESSION['numbers']['user']['roles'])) {
				$_SESSION['numbers']['user']['roles'] = [];
			}
			if (!is_array($role)) $role = [$role];
			$_SESSION['numbers']['user']['roles'] = array_unique(array_merge($_SESSION['numbers']['user']['roles'], $role));
		}
	}
1046405
public function equals($role) {
		return $role->getRole()->id == $this->role->id && $role->getRole()->name == $this->role->name;
	}