Method | Description | Returns |
---|---|---|
current() | Return the current element | Model (WidgetSetting) |
get($key) | Gets the element at the specified key/index. Removing elements from the Collection does not change indices, so use numeric access with caution |
Model (WidgetSetting) |
key() | Return the key of the current element | Model (WidgetSetting) |
next() | Move forward to next element | |
contains(Common\Entities\WidgetSetting $element) | Checks whether an element is contained in the collection. This is an O(n) operation, where n is the size of the collection. |
bool |
containsKey($key) | Checks whether the collection contains an element with the specified key/index. | bool |
getKeys() | Gets all keys/indices of the collection. | array |
getValues() | Gets all values of the collection. | array |
toArray() | Gets an array representation of the collection. | array |
first() | Sets the internal iterator to the first element in the collection and returns the element. | Model (WidgetSetting) |
last() | Sets the internal iterator to the first element in the collection and returns the element. | Model (WidgetSetting) |
indexOf(Common\Entities\WidgetSetting $element) | 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. |
mixed |
getIterator() | Retrieve an external iterator. | Traversable |
count() | Count the elements inside of the collection. | int |
valid() | Checks if current position is valid. Returns true on success or false on failure. | bool |
rewind() | Rewind the Iterator to the first element. | |
toList(string $keyProperty, ?string $valueProperty) | Get a list with key-value-pairs from this collection. If value is null, the whole model will be set in the list |
array |
getAllValues(string $valueProperty) | Get an array list filled with the values found at the valueProperty from this collection | array |
filtered(string $property, $desiredValues, $undesiredValues) | 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. |
Collection (WidgetSetting) |
slice(int $offset, ?int $length) | 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. |
Collection (WidgetSetting) |
sorted(string $keyProperty, string $direction = 'ASC') | 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. | Collection (WidgetSetting) |
shuffled() | Get a shuffled collection from this collection. | Collection (WidgetSetting) |
setSerializedProperties(?array $properties) | Set the properties to be included during serialization for all models contained in this collection. | |
__toString() | Get a string representation of the ResponseModelsCollection. | string |
jsonEncode() | 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 |
string |
Collection
Contains a collection of records. Provides methods for sorting and filtering the collection. Can be iterated in a foreach-loop