Skip to content

Latest commit

 

History

History
70 lines (44 loc) · 3.7 KB

mappable.md

File metadata and controls

70 lines (44 loc) · 3.7 KB

Table of contents


Class: \Somnambulist\Components\Collection\Behaviours\MapReduce\Reduce

Trait Reduce

Visibility Function
public reduce(\callable $callback, \mixed $initial=null) : mixed
Reduces the Collection to a single value, returning it, or $initial if no value

Class: \Somnambulist\Components\Collection\Behaviours\MapReduce\Collapse

Trait Collapse

Visibility Function
public collapse() : \Somnambulist\Components\Collection\Collection/static
Collapse the collection of items into a single array

Class: \Somnambulist\Components\Collection\Behaviours\MapReduce\Map

Trait Map

Visibility Function
public map(callable/string/\string $callable) : \Somnambulist\Components\Collection\Collection/static
Apply the callback to all elements in the collection Note: the callable should accept 2 arguments, the value and the key. For single argument callables only the value will be passed in. The argument count of the callable will attempt to be found. This works on methods, functions and static callable (Class::method).

Class: \Somnambulist\Components\Collection\Behaviours\MapReduce\MapInto

Trait MapInto

Visibility Function
public mapInto(\string $class) : \Somnambulist\Components\Collection\Collection/static
Map the values into a new class.

Class: \Somnambulist\Components\Collection\Behaviours\MapReduce\FlatMap

Trait FlatMap

Visibility Function
public flatMap(\callable $callable) : \Somnambulist\Components\Collection\Collection/static
Map a collection and flatten the result by a single level

Class: \Somnambulist\Components\Collection\Behaviours\MapReduce\Flatten

Trait Flatten

Visibility Function
public flatten() : \Somnambulist\Components\Collection\Collection/static
Returns a new Collection with all sub-sets / arrays merged into one Collection If similar keys exist, they will be overwritten. This method is intended to convert a multi-dimensional array into a key => value array. This method is called recursively through the Collection.
public flattenWithDotKeys() : \Somnambulist\Components\Collection\Collection/static
Returns a new Collection with all sub-sets / arrays merged into one Collection Key names are flattened into dot notation, though overwrites may still occur.