@param string $role

@return int
778429
public static function getRoleId($role)
    {
        $map = [
            self::ENUM_ROLE_ADMIN => self::ENUM_ROLE_ADMIN_ID,
            self::ENUM_ROLE_USER  => self::ENUM_ROLE_USER_ID,
        ];

        // do not check if key exist deliberately. If wrong role is given it will cause an error.
        return $map[$role];
    }
1290240
public function hasRole($role)
    {
        $roles = $this->roles;
        foreach ($roles as $role_obj)
            if ($this->checkRole($role, $role_obj))
                return true;

        return false;
    }
309277
private static function get_role( $role ) {
		global $wp_roles;

		$role_obj = $wp_roles->get_role( $role );

		if ( ! $role_obj ) {
			WP_CLI::error( "'{$role}' role not found." );
		}

		return $role_obj;
	}
1015011
public function hasRoleWithName(string $role): bool
    {
        $this->compileUserRoles();

        return in_array($role, $this->userRoles);
    }
1233051
public static function getBonusByRole(string $role): float
    {
        switch ($role) {
            // To know the number of goals scored by goalkeeper, it needs to be extracted from the MagicPoints
            case Row::GOALKEEPER:
                return GoalsNormalizer::STANDARD_GOALKEEPER_MALUS;
            case Row::DEFENDER:
                return GoalsNormalizer::FORMAT_2017_DEFENDER_GOAL_BONUS;
            case Row::MIDFIELDER:
                return GoalsNormalizer::FORMAT_2017_MIDFIELDER_GOAL_BONUS;
            case Row::PLAYMAKER:
                return GoalsNormalizer::FORMAT_2017_PLAYMAKER_GOAL_BONUS;
            case Row::FORWARD:
            default:
                return GoalsNormalizer::FORMAT_2017_FORWARD_GOAL_BONUS;
        }
    }
758347
private function hasRole($role) {

        if (substr($role, 0, 4) !== 'urn:')
        {
            $role = 'urn:lti:role:ims/lis/' . $role;
        }

        return in_array($role, $this->roles);

    }
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;
    }
878913
public static function fromAccount($role)
    {
        return $role instanceof RoleInterface
            ? new self(ClassUtils::getClass($role), $role->getName())
            : new self('role', $role);
    }
29133
public function removeRole($role)
    {
        $role = strtoupper($role);

        $roles = $this->roles;

        if (in_array($role, $roles)) {
            $remove[]    = $role;
            $this->roles = array_diff($roles, $remove);
        }

        return $this;
    }
1046405
public function equals($role) {
		return $role->getRole()->id == $this->role->id && $role->getRole()->name == $this->role->name;
	}
120377
function comparePositionTo(\CharlotteDunois\Yasmin\Models\Role $role) {
        if($this->position === $role->position) {
            return $role->id <=> $this->id;
        }
        
        return $this->position <=> $role->position;
    }
483506
public static function findByRole(string $role): array
    {
        return static::find()->where(['id' => \Yii::$app->authManager->getUserIdsByRole($role)])->all();
    }
569749
public function getRolePermissions(Role $role)
    {
        $key = $this->getRoleKey($role);

        // If we've saved the caller permissions we don't need to fetch them again.
        if (array_key_exists($key, $this->rolePermissions)) {
            return $this->rolePermissions[$key];
        }

        $results = $this->getTable()->where('role', $role->getRoleName())->get()->toArray();

        return $this->rolePermissions[$key] = PermissionFactory::createFromData($results);
    }
1025512
public function getRoleChildren($role) {
        $children = array();
        if (Zend_Registry::isRegistered('Zend_Acl')) {
            $acl = Zend_Registry::get('Zend_Acl');
            $roles = $acl->getRoles();

            foreach ($roles as $potentialChild) {
                if ($acl->inheritsRole($potentialChild, $role)) {
                    $children[] = $potentialChild;
                }
            }
        }
        return $children;
    }
1285541
public function hasRole($role): bool
    {
        if (is_string($role)) {
            return $this->roles->contains('slug', $role);
        }

        foreach ($role as $r) {
            if (is_string($r)) {
                if ($this->hasRole($r)) {
                    return true;
                }
            } else {
                if ($this->hasRole($r->slug)) {
                    return true;
                }
            }
        }

        return false;
    }
1193664
public function iAmLoggedInAsRole(string $role)
    {
        $found_user = null;
        $users      = $this->getWordpressParameter('users');

        foreach ($users as $user) {
            if (in_array($role, $user['roles'], true)) {
                $found_user = $user;
                break;
            }
        }

        if ($found_user === null) {
            throw new RuntimeException("[W801] User not found for role \"{$role}\"");
        }

        $this->logIn($found_user['username'], $found_user['password']);
    }
477500
public function hasRole($role) {
		if (empty($role) || !\is_numeric($role)) {
			return false;
		}

		if (isset($_SESSION) && isset($_SESSION[self::SESSION_FIELD_ROLES])) {
			$role = (int) $role;

			return (((int) $_SESSION[self::SESSION_FIELD_ROLES]) & $role) === $role;
		}
		else {
			return false;
		}
	}