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

Coredna\Kernel\Models\Response\ResponseModelsCollection

Properties 17

Take no arguments.

# current()
?Model
Return the current element
# key()
?Model
Return the key of the current element
# next()
void
Move forward to next element
# getKeys()
array
Gets all keys/indices of the collection.
# getValues()
array
Gets all values of the collection.
# toArray()
array
Gets an array representation of the collection.
# getFirst()
?Model
Get the first element in the collection without modifying the pointer
# first()
?Model
Sets the internal iterator to the first element in the collection and returns the element.
# getLast()
?Model
Get the last element in the collection without modifying the pointer
# last()
?Model
Sets the internal iterator to the first element in the collection and returns the element.
# getIterator()
Traversable
Retrieve an external iterator.
# count()
int
Count the elements inside of the collection.
# valid()
bool
Checks if current position is valid. Returns true on success or false on failure.
# rewind()
void
Rewind the Iterator to the first element.
# shuffled()
Collection
Get a shuffled collection from this collection.
# __toString()
string
Get a string representation of the ResponseModelsCollection.
# 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.