Core classCoredna\Kernel\Models\Response
Collection
Contains a collection of records.
Provides methods for sorting and filtering the collection.
Can be iterated in a foreach-loop
Properties 17
Take no arguments.
-
#
first() -
?Model - Sets the internal iterator to the first element in the collection and returns the element.
-
#
last() -
?Model - Sets the internal iterator to the first element in the collection and returns the element.
-
#
jsonEncode() -
string - Get a representation of the ResponseModel to be used with json_encode.
Uses the list representation with the id as key in an object that is returned
Methods 10
Take arguments. The API serialises only getters that need none.
-
#
get(mixed $key) -
?Model - Gets the element at the specified key/index.
Removing elements from the Collection does not change indices, so use numeric access with caution -
#
contains(Model $element) -
bool - Checks whether an element is contained in the collection.
This is an O(n) operation, where n is the size of the collection. -
#
containsKey(mixed $key) -
bool - Checks whether the collection contains an element with the specified key/index.
-
#
indexOf(Model $element) -
?mixed - Gets the index/key of a given element. The comparison of two elements is strict, that means not only the value but also the type must match.
For objects this means reference equality.
Returns false if the element was not found. -
#
toList(string $keyProperty, ?string $valueProperty) -
array - Get a list with key-value-pairs from this collection.
If value is null, the whole model will be set in the list -
#
getAllValues(string $valueProperty) -
array - Get an array list filled with the values found at the valueProperty from this collection
-
#
filtered(string $property, mixed $desiredValues, mixed $undesiredValues) -
Collection - Filter collection using the supplied property and the desired value(s).
Only records that have one of the desired value(s) at the property will be returned.
Returns a new collection. -
#
slice(int $offset, ?int $length) -
Collection - Get a new collection by slicing the current collection starting at offset with the specified length.
If $length is null it returns all elements from $offset to the end of the Collection. -
#
sorted(string $keyProperty, string $direction) -
Collection - Get a sorted collection from this collection. As sorting is done in-memory, this is slower than database sorting; thus it is advised to fetch data sorted instead.
-
#
setSerializedProperties(?array $properties) -
void - Set the properties to be included during serialization for all models contained in this collection.
No members match the filter.