Skip to content

Categories

Class  ·  Sharkord\Collections\Categories

Class Categories

An array-accessible, iterable cache of Category objects keyed by category ID (string).

Supports lookup by both integer ID and category name via get().

// Look up by ID or name
$category = $sharkord->categories->collection()->get(1);
$category = $sharkord->categories->collection()->get('🎮 Gaming');
foreach ($sharkord->categories->collection() as $id => $category) {
echo "{$category->name}\n";
}
echo count($sharkord->categories->collection());

Categories constructor.

Parameters

ParameterTypeDescription
$sharkordSharkordReference to the main bot instance.

Retrieves a category by ID or name.

Parameters

ParameterTypeDescription
$identifier`intstring`

Returns \Category|null


Parameters

ParameterTypeDescription
$offsetmixed

Returns bool


Parameters

ParameterTypeDescription
$offsetmixed

Returns ?Category


Parameters

ParameterTypeDescription
$offsetmixed
$valuemixed

Throws

  • \LogicException

Parameters

ParameterTypeDescription
$offsetmixed

Throws

  • \LogicException

Returns int


Returns \ArrayIterator<string,\Category>