Users
Class · Sharkord\Collections\Users
Class Users
An array-accessible, iterable cache of User objects keyed by user ID (string).
Supports lookup by both integer ID and display name via get().
Examples
Section titled “Examples”// Look up by ID or name$user = $sharkord->users->collection()->get(42);$user = $sharkord->users->collection()->get('Buzz');
// Iterate all cached usersforeach ($sharkord->users->collection() as $id => $user) { echo "{$user->name}\n";}
echo count($sharkord->users->collection());Methods
Section titled “Methods”__construct()
Section titled “__construct()”Users constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$sharkord | Sharkord | Reference to the main bot instance. |
Retrieves a user by ID or display name.
Parameters
| Parameter | Type | Description |
|---|---|---|
$identifier | `int | string` |
Returns \User|null
offsetExists()
Section titled “offsetExists()”Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
Returns bool
offsetGet()
Section titled “offsetGet()”Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
Returns ?User
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,\User>