- \Somnambulist\Components\Collection\Behaviours\MapReduce\Reduce
- \Somnambulist\Components\Collection\Behaviours\MapReduce\Collapse
- \Somnambulist\Components\Collection\Behaviours\MapReduce\Map
- \Somnambulist\Components\Collection\Behaviours\MapReduce\MapInto
- \Somnambulist\Components\Collection\Behaviours\MapReduce\FlatMap
- \Somnambulist\Components\Collection\Behaviours\MapReduce\Flatten
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 |
Trait Collapse
Visibility | Function |
---|---|
public | collapse() : \Somnambulist\Components\Collection\Collection/static Collapse the collection of items into a single array |
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). |
Trait MapInto
Visibility | Function |
---|---|
public | mapInto(\string $class) : \Somnambulist\Components\Collection\Collection/static Map the values into a new class. |
Trait FlatMap
Visibility | Function |
---|---|
public | flatMap(\callable $callable) : \Somnambulist\Components\Collection\Collection/static Map a collection and flatten the result by a single level |
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. |