Countable, Serializable, SeekableIterator, ArrayAccess, Traversable, Iterator
ArrayIterator
Name | Description |
---|---|
__call | |
__get | Returns direct value from entity when collection has only one element |
__isset | Returns isset on entity property when collection has only one element |
bindCollection | Bind two collections |
chunk | Splits collection into chunks |
clear | Remove all entities form collection |
distinctOn | Eliminates entities that contains the same value in given property |
extend | Extend collection with entities from another one |
filter | Filter collection from entities not matching criteria given in callback |
first | Returns first entity from collection |
getAllValuesForProperty | Return values from all entities from given property |
getBy | Get collection of entities matching criteria given in callback |
getKeys | Returns collection keys |
getNewCollection | Returns new instance of collection of the same type |
getNext | Returns next entity from collection |
getPrevious | Returns previous entity from collection |
getRandom | returns random entity from collection |
has | Checks if collection has entity with field equals to given value |
isEmpty | Returns true if collection is empty |
isNotEmpty | Returns true if collection is not empty |
last | Returns last entity from collection |
prepend | Prepand entity to the begining of collection |
reindex | Renumber collection keys (from zero to n), keeping values in the same place |
reverse | Return an collection with elements in reverse order |
search | Search for an element with given property and value |
shift | Shift an entity off the begining of collection |
slice | Extract a slice of the collection |
split | Returns collection of collections created by spliting first Collection to a parts |
toArray | Tranform collection to array |
walk | Apply a user supplied function to every member of an Collection |
Name | Description |
---|---|
__construct | Construct an ArrayIterator |
append | Append an element |
asort | Sort array by values |
count | Count elements |
current | Return current array entry |
getArrayCopy | Get array copy |
getFlags | Get flags |
key | Return current array key |
ksort | Sort array by keys |
natcasesort | Sort an array naturally, case insensitive |
natsort | Sort an array naturally |
next | Move to next entry |
offsetExists | Check if offset exists |
offsetGet | Get value for an offset |
offsetSet | Set value for an offset |
offsetUnset | Unset value for an offset |
rewind | Rewind array back to the start |
seek | Seek to position |
serialize | Serialize |
setFlags | Set behaviour flags |
uasort | Sort with a user-defined comparison function and maintain index association |
uksort | Sort by keys using a user-defined comparison function |
unserialize | Unserialize |
valid | Check whether array contains more entries |
Description
__call (void)
Parameters
This function has no parameters.
Return Values
void
Description
public __get (string $name)
Returns direct value from entity when collection has only one element
Parameters
(string) $name
: property name
Return Values
mixed
Throws Exceptions
\LogicException
when collection has more then one element
Description
public __isset (string $name)
Returns isset on entity property when collection has only one element
Parameters
(string) $name
: property name
Return Values
mixed
Throws Exceptions
\LogicException
when collection has more then one element
Description
public bindCollection (\Collection $collection, array $compareKeys, string $propertyName)
Bind two collections
Parameters
(\Collection) $collection
: collection(array) $compareKeys
: The name of the key to compare with from target Collection(string) $propertyName
: The nae of new property that will be created in source Collection
Return Values
static
Description
public chunk (int $size)
Splits collection into chunks
Parameters
(int) $size
Return Values
static
Description
public clear (void)
Remove all entities form collection
Parameters
This function has no parameters.
Return Values
static
Description
public distinctOn (string $propertyName)
Eliminates entities that contains the same value in given property
Parameters
(string) $propertyName
: Name of the property
Return Values
static
Description
public extend (\Collection $data)
Extend collection with entities from another one
Parameters
(\Collection) $data
Return Values
static
Description
public filter (\Closure $callback)
Filter collection from entities not matching criteria given in callback
Parameters
(\Closure) $callback
: callback
Return Values
static
Description
public first (void)
Returns first entity from collection
Parameters
This function has no parameters.
Return Values
\Entity
Description
public getAllValuesForProperty (string $name)
Return values from all entities from given property
Parameters
(string) $name
: name
Return Values
array
Description
public getBy (\Closure $callback)
Get collection of entities matching criteria given in callback
Usage example:
$colleciton->getBy(function($entity) {
return $entity->name == 'John';
});
Parameters
(\Closure) $callback
Return Values
static
Description
public getKeys (void)
Returns collection keys
Parameters
This function has no parameters.
Return Values
array
Description
public getNewCollection (void)
Returns new instance of collection of the same type
Parameters
This function has no parameters.
Return Values
static
Description
public getNext (void)
Returns next entity from collection
Parameters
This function has no parameters.
Return Values
\Entity
Description
public getPrevious (void)
Returns previous entity from collection
Parameters
This function has no parameters.
Return Values
\Entity
Description
public getRandom (void)
returns random entity from collection
Parameters
This function has no parameters.
Return Values
\Entity
Description
public has (string $field, mixed $value)
Checks if collection has entity with field equals to given value
Parameters
(string) $field
: field(mixed) $value
: value
Return Values
bool
Description
public isEmpty (void)
Returns true if collection is empty
Parameters
This function has no parameters.
Return Values
bool
Description
public isNotEmpty (void)
Returns true if collection is not empty
Parameters
This function has no parameters.
Return Values
bool
Description
public last (void)
Returns last entity from collection
Parameters
This function has no parameters.
Return Values
\Entity
Description
public prepend (\Entity $entity)
Prepand entity to the begining of collection
Parameters
(\Entity) $entity
Return Values
static
Description
public reindex (void)
Renumber collection keys (from zero to n), keeping values in the same place
Parameters
This function has no parameters.
Return Values
static
Description
public reverse (void)
Return an collection with elements in reverse order
Parameters
This function has no parameters.
Return Values
static
Description
public search (string $field, mixed $value, bool $strict)
Search for an element with given property and value
Parameters
(string) $field
: name of property(mixed) $value
: value to compare(bool) $strict
: compare value and type of property
Return Values
int|string|bool
Description
public shift (void)
Shift an entity off the begining of collection
Parameters
This function has no parameters.
Return Values
\Entity
Description
public slice (int $offset, int|null $length)
Extract a slice of the collection
Parameters
(int) $offset
(int|null) $length
Return Values
static
Description
public split (int $parts)
Returns collection of collections created by spliting first Collection to a parts
Example:
When collection has 10 element and we would like to split to 3 separate collections:
$splitted = $collection->split(3);
$splitted->count(); // = 3
$splitted[0]->count(); // = 4
$splitted[1]->count(); // = 4
$splitted[3]->count(); // = 2
Parameters
(int) $parts
Return Values
static
Description
public toArray (void)
Tranform collection to array
Parameters
This function has no parameters.
Return Values
array
Description
public walk (\Closure $callback)
Apply a user supplied function to every member of an Collection
Parameters
(\Closure) $callback
: user supplied function
Return Values
static