Categories
Class · Sharkord\Collections\Categories
Class Categories
An array-accessible, iterable cache of Category objects keyed by category ID (string).
Examples
Section titled “Examples”$category = $sharkord->categories->collection()->get(1);
foreach ($sharkord->categories->collection() as $id => $category) { echo "{$category->name}\n";}
echo count($sharkord->categories->collection());Methods
Section titled “Methods”__construct()
Section titled “__construct()”Categories constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$sharkord | Sharkord | Reference to the main bot instance. |
Retrieves a category by ID.
Parameters
| Parameter | Type | Description |
|---|---|---|
$id | `int | string` |
Returns \Category|null
offsetExists()
Section titled “offsetExists()”Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
Returns bool
offsetGet()
Section titled “offsetGet()”Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
Returns ?Category
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,\Category>