Limitable
interface Limitable implements SS_List (View source)
Additional interface for SS_List classes that are limitable - able to have a subset of the list extracted.
All methods in this interface are immutable - they should return new instances with the limit applied, rather than applying the limit in place
Methods
Adds an item to the list, making no guarantees about where it will appear.
Returns a map of a key field to a value field of all the items in the list.
Returns the first item in the list where the key field is equal to the value.
Details
array
toArray()
Returns all the items in the list in an array.
array
toNestedArray()
Returns the contents of the list as an array of maps.
add(mixed $item)
Adds an item to the list, making no guarantees about where it will appear.
remove(mixed $item)
Removes an item from the list.
mixed
first()
Returns the first item in the list.
mixed
last()
Returns the last item in the list.
Map
map(string $keyfield = 'ID', string $titlefield = 'Title')
Returns a map of a key field to a value field of all the items in the list.
mixed
find(string $key, mixed $value)
Returns the first item in the list where the key field is equal to the value.
array
column(string $colName = "ID")
Returns an array of a single field value for all items in the list.
$this
each(callable $callback)
Walks the list using the specified callback
Limitable
limit(int $limit, int $offset = 0)
Returns a new instance of this list where no more than $limit records are included.
If $offset is specified, then that many records at the beginning of the list will be skipped. This matches the behaviour of the SQL LIMIT clause.