interface Enumerable implements Arrayable, Countable, IteratorAggregate, Jsonable, JsonSerializable (View source)

Methods

toArray()

No description

string
toJson(int $options = 0)

Convert the object to its JSON representation.

from  Jsonable
static 
make($items = [])

No description

static Enumerable
times(int $number, callable $callback = null)

Create a new instance by invoking the callback a given amount of times.

static Enumerable
range(int $from, int $to)

Create a collection with the given range.

static 
wrap($value)

No description

static 
unwrap($value)

No description

static 
empty()

No description

array
all()

Get all items in the enumerable.

float|int|null
average($callback = null)

Alias for the "avg" method.

float|int|null
median($key = null)

Get the median of a given key.

array<int,float|int>|null
mode($key = null)

Get the mode of a given key.

collapse()

No description

bool
some($key, mixed $operator = null, mixed $value = null)

Alias for the "contains" method.

bool
containsStrict($key, TValue|null $value = null)

Determine if an item exists, using strict comparison.

float|int|null
avg($callback = null)

Get the average value of a given key.

bool
contains($key, mixed $operator = null, mixed $value = null)

Determine if an item exists in the enumerable.

crossJoin(...$lists)

No description

never
dd(mixed ...$args)

Dump the collection and end the script.

$this
dump()

Dump the collection.

diff($items)

No description

diffUsing($items, callable $callback)

No description

diffAssoc($items)

No description

diffAssocUsing($items, callable $callback)

No description

diffKeys($items)

No description

diffKeysUsing($items, callable $callback)

No description

duplicates($callback = null, $strict = false)

No description

duplicatesStrict($callback = null)

No description

$this
each(callable $callback)

Execute a callback over each item.

eachSpread(callable $callback)

No description

bool
every($key, mixed $operator = null, mixed $value = null)

Determine if all items pass the given truth test.

except($keys)

No description

filter(callable $callback = null)

No description

$this|TWhenReturnType
when(bool $value, callable $callback = null, callable $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

$this|TWhenEmptyReturnType
whenEmpty(callable $callback, callable $default = null)

Apply the callback if the collection is empty.

$this|TWhenNotEmptyReturnType
whenNotEmpty(callable $callback, callable $default = null)

Apply the callback if the collection is not empty.

$this|TUnlessReturnType
unless(bool $value, callable $callback, callable $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

$this|TUnlessEmptyReturnType
unlessEmpty(callable $callback, callable $default = null)

Apply the callback unless the collection is empty.

$this|TUnlessNotEmptyReturnType
unlessNotEmpty(callable $callback, callable $default = null)

Apply the callback unless the collection is not empty.

where($key, $operator = null, $value = null)

No description

whereNull($key = null)

No description

whereNotNull($key = null)

No description

whereStrict($key, $value)

No description

whereIn($key, $values, $strict = false)

No description

whereInStrict($key, $values)

No description

whereBetween($key, $values)

No description

whereNotBetween($key, $values)

No description

whereNotIn($key, $values, $strict = false)

No description

whereNotInStrict($key, $values)

No description

whereInstanceOf($type)

No description

first(callable $callback = null, $default = null)

No description

TValue|null
firstWhere(string $key, mixed $operator = null, mixed $value = null)

Get the first item by the given key value pair.

flatten($depth = INF)

No description

flip()

No description

get($key, $default = null)

No description

groupBy($groupBy, $preserveKeys = false)

No description

keyBy($keyBy)

No description

bool
has($key)

Determine if an item exists in the collection by key.

string
implode(string $value, string|null $glue = null)

Concatenate values of a given key as a string.

intersect($items)

No description

intersectByKeys($items)

No description

bool
isEmpty()

Determine if the collection is empty or not.

bool
isNotEmpty()

Determine if the collection is not empty.

string
join(string $glue, string $finalGlue = '')

Join all items from the collection using a string. The final items can use a separate glue string.

keys()

No description

last(callable $callback = null, $default = null)

No description

map(callable $callback)

No description

mapSpread(callable $callback)

No description

mapToDictionary(callable $callback)

No description

mapToGroups(callable $callback)

No description

mapWithKeys(callable $callback)

No description

flatMap(callable $callback)

No description

mapInto($class)

No description

merge($items)

No description

mergeRecursive($items)

No description

combine($values)

No description

union($items)

No description

TValue
min($callback = null)

Get the min value of a given key.

TValue
max($callback = null)

Get the max value of a given key.

nth($step, $offset = 0)

No description

only($keys)

No description

forPage($page, $perPage)

No description

partition($key, $operator = null, $value = null)

No description

concat($source)

No description

random($number = null)

No description

TReduceReturnType
reduce(callable $callback, TReduceInitial $initial = null)

Reduce the collection to a single value.

replace($items)

No description

replaceRecursive($items)

No description

reverse()

No description

TKey|bool
search($value, bool $strict = false)

Search the collection for a given value and return the corresponding key if successful.

shuffle($seed = null)

No description

skip($count)

No description

skipUntil($value)

No description

skipWhile($value)

No description

slice($offset, $length = null)

No description

split($numberOfGroups)

No description

TValue
sole($key = null, mixed $operator = null, mixed $value = null)

Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception.

chunk($size)

No description

chunkWhile(callable $callback)

No description

sort($callback = null)

No description

sortDesc($options = SORT_REGULAR)

No description

sortBy($callback, $options = SORT_REGULAR, $descending = false)

No description

sortByDesc($callback, $options = SORT_REGULAR)

No description

sortKeys($options = SORT_REGULAR, $descending = false)

No description

sortKeysDesc($options = SORT_REGULAR)

No description

mixed
sum($callback = null)

Get the sum of the given values.

take($limit)

No description

takeUntil($value)

No description

takeWhile($value)

No description

$this
tap(callable $callback)

Pass the collection to the given callback and then return it.

TPipeReturnType
pipe(callable $callback)

Pass the enumerable to the given callback and return the result.

pluck($value, $key = null)

No description

reject($callback = true)

No description

unique($key = null, $strict = false)

No description

uniqueStrict($key = null)

No description

values()

No description

pad($size, $value)

No description

countBy($callback = null)

No description

zip($items)

No description

TValue>
collect()

Collect the values into a collection.

string
__toString()

Convert the collection to its string representation.

static void
proxy(string $method)

Add a method to the list of proxied methods.

mixed
__get(string $key)

Dynamically access collection proxies.

Details

toArray()

No description

string toJson(int $options = 0)

Convert the object to its JSON representation.

Parameters

int $options

Return Value

string

static make($items = [])

No description

Parameters

$items

static Enumerable times(int $number, callable $callback = null)

Create a new instance by invoking the callback a given amount of times.

Parameters

int $number
callable $callback

Return Value

Enumerable

static Enumerable range(int $from, int $to)

Create a collection with the given range.

Parameters

int $from
int $to

Return Value

Enumerable

static wrap($value)

No description

Parameters

$value

static unwrap($value)

No description

Parameters

$value

static empty()

No description

array all()

Get all items in the enumerable.

Return Value

array

float|int|null average($callback = null)

Alias for the "avg" method.

Parameters

$callback

Return Value

float|int|null

float|int|null median($key = null)

Get the median of a given key.

Parameters

$key

Return Value

float|int|null

array<int,float|int>|null mode($key = null)

Get the mode of a given key.

Parameters

$key

Return Value

array<int,float|int>|null

collapse()

No description

bool some($key, mixed $operator = null, mixed $value = null)

Alias for the "contains" method.

Parameters

$key
mixed $operator
mixed $value

Return Value

bool

bool containsStrict($key, TValue|null $value = null)

Determine if an item exists, using strict comparison.

Parameters

$key
TValue|null $value

Return Value

bool

float|int|null avg($callback = null)

Get the average value of a given key.

Parameters

$callback

Return Value

float|int|null

bool contains($key, mixed $operator = null, mixed $value = null)

Determine if an item exists in the enumerable.

Parameters

$key
mixed $operator
mixed $value

Return Value

bool

crossJoin(...$lists)

No description

Parameters

...$lists

never dd(mixed ...$args)

Dump the collection and end the script.

Parameters

mixed ...$args

Return Value

never

$this dump()

Dump the collection.

Return Value

$this

diff($items)

No description

Parameters

$items

diffUsing($items, callable $callback)

No description

Parameters

$items
callable $callback

diffAssoc($items)

No description

Parameters

$items

diffAssocUsing($items, callable $callback)

No description

Parameters

$items
callable $callback

diffKeys($items)

No description

Parameters

$items

diffKeysUsing($items, callable $callback)

No description

Parameters

$items
callable $callback

duplicates($callback = null, $strict = false)

No description

Parameters

$callback
$strict

duplicatesStrict($callback = null)

No description

Parameters

$callback

$this each(callable $callback)

Execute a callback over each item.

Parameters

callable $callback

Return Value

$this

eachSpread(callable $callback)

No description

Parameters

callable $callback

bool every($key, mixed $operator = null, mixed $value = null)

Determine if all items pass the given truth test.

Parameters

$key
mixed $operator
mixed $value

Return Value

bool

except($keys)

No description

Parameters

$keys

filter(callable $callback = null)

No description

Parameters

callable $callback

$this|TWhenReturnType when(bool $value, callable $callback = null, callable $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

bool $value
callable $callback
callable $default

Return Value

$this|TWhenReturnType

$this|TWhenEmptyReturnType whenEmpty(callable $callback, callable $default = null)

Apply the callback if the collection is empty.

Parameters

callable $callback
callable $default

Return Value

$this|TWhenEmptyReturnType

$this|TWhenNotEmptyReturnType whenNotEmpty(callable $callback, callable $default = null)

Apply the callback if the collection is not empty.

Parameters

callable $callback
callable $default

Return Value

$this|TWhenNotEmptyReturnType

$this|TUnlessReturnType unless(bool $value, callable $callback, callable $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

bool $value
callable $callback
callable $default

Return Value

$this|TUnlessReturnType

$this|TUnlessEmptyReturnType unlessEmpty(callable $callback, callable $default = null)

Apply the callback unless the collection is empty.

Parameters

callable $callback
callable $default

Return Value

$this|TUnlessEmptyReturnType

$this|TUnlessNotEmptyReturnType unlessNotEmpty(callable $callback, callable $default = null)

Apply the callback unless the collection is not empty.

Parameters

callable $callback
callable $default

Return Value

$this|TUnlessNotEmptyReturnType

where($key, $operator = null, $value = null)

No description

Parameters

$key
$operator
$value

whereNull($key = null)

No description

Parameters

$key

whereNotNull($key = null)

No description

Parameters

$key

whereStrict($key, $value)

No description

Parameters

$key
$value

whereIn($key, $values, $strict = false)

No description

Parameters

$key
$values
$strict

whereInStrict($key, $values)

No description

Parameters

$key
$values

whereBetween($key, $values)

No description

Parameters

$key
$values

whereNotBetween($key, $values)

No description

Parameters

$key
$values

whereNotIn($key, $values, $strict = false)

No description

Parameters

$key
$values
$strict

whereNotInStrict($key, $values)

No description

Parameters

$key
$values

whereInstanceOf($type)

No description

Parameters

$type

first(callable $callback = null, $default = null)

No description

Parameters

callable $callback
$default

TValue|null firstWhere(string $key, mixed $operator = null, mixed $value = null)

Get the first item by the given key value pair.

Parameters

string $key
mixed $operator
mixed $value

Return Value

TValue|null

flatten($depth = INF)

No description

Parameters

$depth

flip()

No description

get($key, $default = null)

No description

Parameters

$key
$default

groupBy($groupBy, $preserveKeys = false)

No description

Parameters

$groupBy
$preserveKeys

keyBy($keyBy)

No description

Parameters

$keyBy

bool has($key)

Determine if an item exists in the collection by key.

Parameters

$key

Return Value

bool

string implode(string $value, string|null $glue = null)

Concatenate values of a given key as a string.

Parameters

string $value
string|null $glue

Return Value

string

intersect($items)

No description

Parameters

$items

intersectByKeys($items)

No description

Parameters

$items

bool isEmpty()

Determine if the collection is empty or not.

Return Value

bool

bool isNotEmpty()

Determine if the collection is not empty.

Return Value

bool

string join(string $glue, string $finalGlue = '')

Join all items from the collection using a string. The final items can use a separate glue string.

Parameters

string $glue
string $finalGlue

Return Value

string

keys()

No description

last(callable $callback = null, $default = null)

No description

Parameters

callable $callback
$default

map(callable $callback)

No description

Parameters

callable $callback

mapSpread(callable $callback)

No description

Parameters

callable $callback

mapToDictionary(callable $callback)

No description

Parameters

callable $callback

mapToGroups(callable $callback)

No description

Parameters

callable $callback

mapWithKeys(callable $callback)

No description

Parameters

callable $callback

flatMap(callable $callback)

No description

Parameters

callable $callback

mapInto($class)

No description

Parameters

$class

merge($items)

No description

Parameters

$items

mergeRecursive($items)

No description

Parameters

$items

combine($values)

No description

Parameters

$values

union($items)

No description

Parameters

$items

TValue min($callback = null)

Get the min value of a given key.

Parameters

$callback

Return Value

TValue

TValue max($callback = null)

Get the max value of a given key.

Parameters

$callback

Return Value

TValue

nth($step, $offset = 0)

No description

Parameters

$step
$offset

only($keys)

No description

Parameters

$keys

forPage($page, $perPage)

No description

Parameters

$page
$perPage

partition($key, $operator = null, $value = null)

No description

Parameters

$key
$operator
$value

concat($source)

No description

Parameters

$source

random($number = null)

No description

Parameters

$number

TReduceReturnType reduce(callable $callback, TReduceInitial $initial = null)

Reduce the collection to a single value.

Parameters

callable $callback
TReduceInitial $initial

Return Value

TReduceReturnType

replace($items)

No description

Parameters

$items

replaceRecursive($items)

No description

Parameters

$items

reverse()

No description

Search the collection for a given value and return the corresponding key if successful.

Parameters

$value
bool $strict

Return Value

TKey|bool

shuffle($seed = null)

No description

Parameters

$seed

skip($count)

No description

Parameters

$count

skipUntil($value)

No description

Parameters

$value

skipWhile($value)

No description

Parameters

$value

slice($offset, $length = null)

No description

Parameters

$offset
$length

split($numberOfGroups)

No description

Parameters

$numberOfGroups

TValue sole($key = null, mixed $operator = null, mixed $value = null)

Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception.

Parameters

$key
mixed $operator
mixed $value

Return Value

TValue

Exceptions

ItemNotFoundException
MultipleItemsFoundException

chunk($size)

No description

Parameters

$size

chunkWhile(callable $callback)

No description

Parameters

callable $callback

sort($callback = null)

No description

Parameters

$callback

sortDesc($options = SORT_REGULAR)

No description

Parameters

$options

sortBy($callback, $options = SORT_REGULAR, $descending = false)

No description

Parameters

$callback
$options
$descending

sortByDesc($callback, $options = SORT_REGULAR)

No description

Parameters

$callback
$options

sortKeys($options = SORT_REGULAR, $descending = false)

No description

Parameters

$options
$descending

sortKeysDesc($options = SORT_REGULAR)

No description

Parameters

$options

mixed sum($callback = null)

Get the sum of the given values.

Parameters

$callback

Return Value

mixed

take($limit)

No description

Parameters

$limit

takeUntil($value)

No description

Parameters

$value

takeWhile($value)

No description

Parameters

$value

$this tap(callable $callback)

Pass the collection to the given callback and then return it.

Parameters

callable $callback

Return Value

$this

TPipeReturnType pipe(callable $callback)

Pass the enumerable to the given callback and return the result.

Parameters

callable $callback

Return Value

TPipeReturnType

pluck($value, $key = null)

No description

Parameters

$value
$key

reject($callback = true)

No description

Parameters

$callback

unique($key = null, $strict = false)

No description

Parameters

$key
$strict

uniqueStrict($key = null)

No description

Parameters

$key

values()

No description

pad($size, $value)

No description

Parameters

$size
$value

countBy($callback = null)

No description

Parameters

$callback

zip($items)

No description

Parameters

$items

TValue> collect()

Collect the values into a collection.

Return Value

TValue>

string __toString()

Convert the collection to its string representation.

Return Value

string

static void proxy(string $method)

Add a method to the list of proxied methods.

Parameters

string $method

Return Value

void

mixed __get(string $key)

Dynamically access collection proxies.

Parameters

string $key

Return Value

mixed

Exceptions

Exception