DiscordPHP-MTG Documentation

Collection
in package
implements ExCollectionInterface, JsonSerializable uses CollectionTrait

Collection of items. Inspired by Laravel Collections. A local copy of DiscordPHP's `Collection` so MTG code has an `MTG\Helpers`-namespaced type; behaviour comes entirely from {@see CollectionTrait}.

Tags
see
Collection

The upstream this mirrors

CollectionTrait

The shared implementation

since
5.0.0

No longer extends Laravel's BaseCollection

4.0.0

Table of Contents

Interfaces

ExCollectionInterface
JsonSerializable

Properties

$class  : string
Class type allowed into the collection.
$discrim  : ?string
The collection discriminator.
$items  : array<string|int, mixed>
The items contained in the collection.

Methods

__construct()  : mixed
Create a new Collection.
for()  : ExCollectionInterface
Creates a collection for a class.
from()  : ExCollectionInterface
Creates a collection from an array.

Properties

$class

Class type allowed into the collection.

protected string $class

$discrim

The collection discriminator.

protected ?string $discrim

$items

The items contained in the collection.

protected array<string|int, mixed> $items

Methods

__construct()

Create a new Collection.

public __construct([array<string|int, mixed> $items = [] ][, ?string $discrim = 'id' ][, ?string $class = null ]) : mixed
Parameters
$items : array<string|int, mixed> = []
$discrim : ?string = 'id'
$class : ?string = null

for()

Creates a collection for a class.

public static for(string $class[, ?string $discrim = 'id' ]) : ExCollectionInterface
Parameters
$class : string
$discrim : ?string = 'id'
Return values
ExCollectionInterface

from()

Creates a collection from an array.

public static from([array<string|int, mixed> $items = [] ][, ?string $discrim = 'id' ][, ?string $class = null ]) : ExCollectionInterface
Parameters
$items : array<string|int, mixed> = []
$discrim : ?string = 'id'
$class : ?string = null
Return values
ExCollectionInterface
On this page

Search results