Documentation

Packages extends CachedCollection
in package

Class Packages

Table of Contents

Properties

$cache  : array<string|int, mixed>
$items  : array<string|int, mixed>

Methods

__call()  : mixed
Convert function calls for the existing keys into their values.
__clone()  : mixed
Clone the iterator.
__construct()  : mixed
CachedCollection constructor.
__toString()  : string
Convents iterator to a comma separated list.
append()  : $this
Append new elements to the list.
filter()  : $this
Filter elements from the list
first()  : mixed
Get the first item
indexOf()  : string|int|false
last()  : mixed
Get the last item
nth()  : mixed|bool
Return nth item.
prev()  : mixed
Return previous item.
random()  : $this
Pick one or more random entries.
remove()  : void
Remove item from the list.
reverse()  : $this
Reverse the Iterator
shuffle()  : $this
Shuffle items.
slice()  : $this
Slice the list.
sort()  : $this|array<string|int, mixed>
Sorts elements from the list and returns a copy of the list in the proper order

Properties

$items

protected array<string|int, mixed> $items = []

Methods

__call()

Convert function calls for the existing keys into their values.

public __call(string $key, mixed $args) : mixed
Parameters
$key : string
$args : mixed
Attributes
#[ReturnTypeWillChange]

__clone()

Clone the iterator.

public __clone() : mixed
Attributes
#[ReturnTypeWillChange]

__construct()

CachedCollection constructor.

public __construct() : mixed

__toString()

Convents iterator to a comma separated list.

public __toString() : string
Attributes
#[ReturnTypeWillChange]
Return values
string

append()

Append new elements to the list.

public append(array<string|int, mixed>|Iterator $items) : $this
Parameters
$items : array<string|int, mixed>|Iterator

Items to be appended. Existing keys will be overridden with the new values.

Return values
$this

filter()

Filter elements from the list

public filter([callable|null $callback = null ]) : $this
Parameters
$callback : callable|null = null

A function the receives ($value, $key) and must return a boolean to indicate filter status

Return values
$this

first()

Get the first item

public first() : mixed

indexOf()

public indexOf(mixed $needle) : string|int|false
Parameters
$needle : mixed

Searched value.

Return values
string|int|false

Key if found, otherwise false.

last()

Get the last item

public last() : mixed

nth()

Return nth item.

public nth(int $key) : mixed|bool
Parameters
$key : int
Return values
mixed|bool

prev()

Return previous item.

public prev() : mixed

random()

Pick one or more random entries.

public random([int $num = 1 ]) : $this
Parameters
$num : int = 1

Specifies how many entries should be picked.

Return values
$this

remove()

Remove item from the list.

public remove(string $key) : void
Parameters
$key : string

reverse()

Reverse the Iterator

public reverse() : $this
Return values
$this

shuffle()

Shuffle items.

public shuffle() : $this
Return values
$this

slice()

Slice the list.

public slice(int $offset[, int|null $length = null ]) : $this
Parameters
$offset : int
$length : int|null = null
Return values
$this

sort()

Sorts elements from the list and returns a copy of the list in the proper order

public sort([callable|null $callback = null ][, bool $desc = false ]) : $this|array<string|int, mixed>
Parameters
$callback : callable|null = null
$desc : bool = false
Return values
$this|array<string|int, mixed>

        
On this page

Search results