Parses role id from object, array
or a string.

@param object|array|string|int $role
@return int
350800
protected function parseRoleId($role)
    {
        if ( is_string($role) || is_numeric($role) ) {

            $model = config('acl.role', 'Kodeine\Acl\Models\Eloquent\Role');
            $key = is_numeric($role) ? 'id' : 'slug';
            $alias = (new $model)->where($key, $role)->first();

            if ( ! is_object($alias) || ! $alias->exists ) {
                throw new \InvalidArgumentException('Specified role ' . $key . ' does not exists.');
            }

            $role = $alias->getKey();
        }

        $model = '\Illuminate\Database\Eloquent\Model';
        if ( is_object($role) && $role instanceof $model ) {
            $role = $role->getKey();
        }

        return (int) $role;
    }
445554
public function getRole($role)
    {
        if (!$this->hasRole($role)) {
            throw new ConfigurationException(sprintf('Role "%s" does not exist.', $role));
        }

        return $this->roles[$role];
    }
1120871
public function getRelativeRoleName($role)
    {
        $roles = $this->collectRelativeRoles();
        if (isset($roles[$role])) {
            return $roles[$role];
        }
    }
450869
public function isAn($role)
    {
        $roles = func_get_args();

        $clipboard = $this->getClipboardInstance();

        return $clipboard->checkRole($this, $roles, 'or');
    }
303209
public function count_users( $role ) {

		$count_users = count_users();

		$avail_roles = array();

		foreach ( $count_users['avail_roles'] as $count_role => $count ) {
			$avail_roles[ $count_role ] = $count;
		}

		if ( empty( $role ) ) {
			return $avail_roles;
		}

		if ( ! isset( $avail_roles[ $role ] ) ) {
			$avail_roles[ $role ] = 0;
		}

		return $avail_roles[ $role ];
	}
483506
public static function findByRole(string $role): array
    {
        return static::find()->where(['id' => \Yii::$app->authManager->getUserIdsByRole($role)])->all();
    }
938098
public function hasRole($role)
    {
        foreach ($this->roles as $roleObj) {
            if($role == $roleObj->getRole()){
                return true;
            }
        }
        return false;
    }
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;
    }
1290240
public function hasRole($role)
    {
        $roles = $this->roles;
        foreach ($roles as $role_obj)
            if ($this->checkRole($role, $role_obj))
                return true;

        return false;
    }
1281147
public function addRole($role)
    {
        $role = strtoupper($role);
        if (static::ROLE_DEFAULT === $role) {
            return $this;
        }

        if (!$this->hasRole($role)) {
            $this->roles[] = $role;
        }

        return $this;
    }
759003
public function translateToRoleId($role)
    {
        $lookup = array_flip($this->_roleTranslations);

        if (isset($lookup[$role])) {
            return $lookup[$role];
        }

        return $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;
    }
1087330
public function assignRole($role)
    {
        if (Role::count() === 0) {
            throw new \Exception('No roles have been created.');
        }

        return $this->roles()->save(
            Role::whereName($role)->firstOrFail()
        );
    }
977680
public function get($role)
    {
        if (is_scalar($role)) {
            $role = new Role($role);
        } elseif (!$role instanceof Role) {
            throw new \InvalidArgumentException('$role is expected to be of type string or Gobline\Acl\Role');
        }

        $roleName = $role->getName();

        if (!$this->has($role)) {
            throw new \InvalidArgumentException('Role "'.$roleName.'" not found');
        }

        return $this->roles[$roleName];
    }
639547
public function getRole($role) {
		
		if(false === is_string($role)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($role)), E_USER_ERROR);
		}

		foreach($this -> permissions as $type => $resources) {

			if($role === $type) {
				
				$p = new Resources();
				$p -> setResources($resources);

				return $p;
			}
		}

		return null;
	}
529590
public function hasRole($role) {
        $roles = (array) $this->Session->read('Acl.roles');

        if (is_numeric($role)) {
            return isset($roles[$role]);
        }

        return in_array($role, $roles);
    }
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));
		}
	}