ArrayCollection
Borrowed from ramsey/collection
- Full name:
\Qubus\Support\Collection\ArrayCollection
- Parent class:
\Qubus\Support\Collection\Collection
Properties
items
The items of this array.
Methods
__construct
Constructs a new array object.
Parameters:
Parameter | Type | Description |
---|---|---|
$items | array | The initial items to add to array. |
type
Collection type.
Inherited methods
__construct
Constructs a new array object.
Parameters:
Parameter | Type | Description |
---|---|---|
$items | array | The initial items to add to array. |
getIterator
Returns array as iterator.
offsetExists
Returns true
if the given offset exists in the array.
Parameters:
Parameter | Type | Description |
---|---|---|
$offset | mixed | The offset to check. |
offsetGet
Returns the value at the specified offset.
Parameters:
Parameter | Type | Description |
---|---|---|
$offset | mixed | The offset for which a value should be returned. |
Return Value:
The value stored at the offset, or null if the offset does not exist.
offsetSet
Sets the given value to the given offset in the array.
Parameters:
Parameter | Type | Description |
---|---|---|
$offset | mixed | The offset to set. |
$value | mixed | The value to set at the given offset. |
Throws:
offsetUnset
Removes the given offset and its value from the array.
Parameters:
Parameter | Type | Description |
---|---|---|
$offset | mixed | The offset to remove from the array. |
serialize
Returns a JSON string.
unserialize
Converts a serialized string representation into an instance object.
Parameters:
Parameter | Type | Description |
---|---|---|
$items | array | A PHP array to unserialize. |
count
Total number of collections.
clear
Removes all items from array instance.
toArray
Returns an instance as an array.
isEmpty
Returns true
if array is empty.
extractValue
Extracts the value of the given property or method from the object.
Parameters:
Parameter | Type | Description |
---|---|---|
$object | mixed | The object to extract the value from. |
$propertyOrMethod | string|null | The property or method for which the value should be extracted. |
Return Value:
the value extracted from the specified property or method.
Throws:
if the method or property is not defined.
toolValueToString
Returns a string representation of the value.
- null value:
'NULL'
- boolean:
'TRUE'
,'FALSE'
- array:
'Array'
- scalar: converted-value
- resource:
'(type resource #number)'
- object with
__toString()
: result of__toString()
- object DateTime: ISO 8601 date
- object:
'(className Object)'
- anonymous function: same as object
Parameters:
Parameter | Type | Description |
---|---|---|
$value | mixed | the value to return as a string. |
checkType
Returns true if value is of specified type.
Parameters:
Parameter | Type | Description |
---|---|---|
$type | string | |
$value | mixed |
add
Add an item to the collection.
Parameters:
Parameter | Type | Description |
---|---|---|
$item | mixed |
getType
Returns the type of the collection.
contains
Returns true
if this collection contains the specified element.
Parameters:
Parameter | Type | Description |
---|---|---|
$element | mixed | The element to check whether the collection contains. |
$strict | bool | Whether to perform a strict type check on the value. |
map
Returns a new instance of the collection with the callback function $callable applied to each item
Parameters:
Parameter | Type | Description |
---|---|---|
$callable | callable |
each
Applies the callback function $callable to each item in the collection.
Parameters:
Parameter | Type | Description |
---|---|---|
$callable | callable |
flip
Flip the items in the collection.
filter
Filter the collection items through the callable.
Parameters:
Parameter | Type | Description |
---|---|---|
$callable | callable |
get
Get the specified item from the collection.
Parameters:
Parameter | Type | Description |
---|---|---|
$key | mixed |
Throws:
slice
Slice the underlying collection array.
Parameters:
Parameter | Type | Description |
---|---|---|
$offset | int | |
$length | int|null |
nth
Create a new collection consisting of every n-th element.
Parameters:
Parameter | Type | Description |
---|---|---|
$step | int | |
$offset | int |
reject
Reject the collection items through the callable.
public reject(callable $callable): \Qubus\Support\Collection\Collection|\Qubus\Support\Collection\BaseCollection
Parameters:
Parameter | Type | Description |
---|---|---|
$callable | callable |
push
Push an item to the collection.
Parameters:
Parameter | Type | Description |
---|---|---|
$value | mixed |
put
Put the specified item in the collection with the given key.
Parameters:
Parameter | Type | Description |
---|---|---|
$key | mixed | |
$value | mixed |
values
Returns a new Collection instance containing an indexed array of values.
flatten
Returns a new Collection instance containing a flattened array of items.
sort
Sort the collection of item values through a user-defined comparison function.
Parameters:
Parameter | Type | Description |
---|---|---|
$callback | callable|null |
sortByKey
Sort the collection of item keys through a user-defined comparison function.
Parameters:
Parameter | Type | Description |
---|---|---|
$callback | callable|null |
reverse
Reverse the collection items.
search
Search the collection for a given value and return the corresponding key if successful.
Parameters:
Parameter | Type | Description |
---|---|---|
$value | mixed | |
$strict | bool |
groupBy
Group an associative array by a field or using a callback.
Parameters:
Parameter | Type | Description |
---|---|---|
$callback | callable |
keys
Returns a new Collection instance containing an indexed array of keys.
all
Returns all items in collection.
pop
Get and remove the last item from the collection.
last
Get the last item from the collection.
shift
Get and remove the first item from the collection.
first
Get the first item from the collection.
sum
Get the sum of the collection items.
Parameters:
Parameter | Type | Description |
---|---|---|
$callback | mixed|null |
merge
Merge items with current collection.
Parameters:
Parameter | Type | Description |
---|---|---|
$items | array |
Throws:
column
Returns the values from the given property or method.
Parameters:
Parameter | Type | Description |
---|---|---|
$propertyOrMethod | string | The property or method name to filter by. |
Throws:
replace
Replace the collection items with the given items.
Parameters:
Parameter | Type | Description |
---|---|---|
$items | array |
replaceRecursive
Recursively replace the collection items with the given items.
Parameters:
Parameter | Type | Description |
---|---|---|
$items | array |
type
Collection type.
- This method is abstract.
items
Returns an array of collections.
Automatically generated on 2025-10-13