Roles
Class · Sharkord\Collections\Roles
Class Roles
An array-accessible, iterable cache of Role objects keyed by role ID (string).
Examples
Section titled “Examples”$role = $sharkord->roles->collection()->get(1);
foreach ($sharkord->roles->collection() as $id => $role) { echo "{$role->name}\n";}
echo count($sharkord->roles->collection());Methods
Section titled “Methods”__construct()
Section titled “__construct()”Roles constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$sharkord | Sharkord | Reference to the main bot instance. |
Retrieves a role by ID.
Parameters
| Parameter | Type | Description |
|---|---|---|
$id | `int | string` |
Returns \Role|null
offsetExists()
Section titled “offsetExists()”Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
Returns bool
offsetGet()
Section titled “offsetGet()”Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
Returns ?Role
offsetSet()
Section titled “offsetSet()”Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed | |
$value | mixed |
Throws
\LogicException
offsetUnset()
Section titled “offsetUnset()”Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
Throws
\LogicException
count()
Section titled “count()”Returns int
getIterator()
Section titled “getIterator()”Returns \ArrayIterator<string,\Role>