Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 2.58 KB

aggregates.md

File metadata and controls

30 lines (20 loc) · 2.58 KB

Table of contents


Class: \Somnambulist\Components\Collection\Behaviours\Aggregate\AggregateValues

Trait AggregateValues

Visibility Function
public average(\null $key=null) : float/int
Returns the average of all values from the collection using the key
public max(\null $key=null) : mixed int/float or an array of the key => value that is the max value
Returns the highest value from the collection of values Key can be a string key or callable. Based on Laravel: Illuminate\Support\Collection.max
public median(\null $key=null) : float/int
Returns the median value of the min/max from the key
public min(\null $key=null) : mixed int/float or an array of the key => value that is the min value
Returns the lowest value from the collection of values Key can be a string key or callable. Based on Laravel: Illuminate\Support\Collection.min
public modal(\null $key=null) : mixed int/float or an array of the key => value that are the modal values
Returns the modal (most frequent) value from the collection based on the key In the case of a single modal, returns that value (int/float). In the case of several modals, returns an array of each value If every value is a modal, returns false. If you have many modals, consider grouping by occurrence instead.
public sum(\null $key=null) : float/int
Sum items in the collection, optionally matching the key / callable Based on Laravel: Illuminate\Support\Collection.sum

Class: \Somnambulist\Components\Collection\Behaviours\Aggregate\CountBy

Trait CountBy

Visibility Function
public countBy(\callable $callback=null) : \Somnambulist\Components\Collection\Collection/static
Count the number of items in the collection using a given test