PHP Class FOF30\Model\DataModel\Collection

Inheritance: extends FOF30\Utils\Collection
Show file Open project: akeeba/fof Class Usage Examples

Public Methods

Method Description
__call ( string $name, array $arguments ) Magic method which allows you to run a DataModel method to all items in the collection.
add ( mixed $item ) : Collection Add an item to the collection.
contains ( mixed $key ) : boolean Determine if a key exists in the collection.
diff ( Collection | array $collection ) : Collection Diff the collection with the given items.
fetch ( string $key ) : Collection Fetch a nested element of the collection.
find ( mixed $key, mixed $default = null ) : DataModel Find a model in the collection by key.
intersect ( Collection | array $collection ) : Collection Intersect the collection with the given items.
max ( string $key ) : mixed Get the max value of a given key.
merge ( Collection | array $collection ) : Collection Merge the collection with the given items.
min ( string $key ) : mixed Get the min value of a given key.
modelKeys ( ) : array Get the array of primary keys
removeById ( mixed $key ) : void Remove an item in the collection by key
toBase ( ) : Collection Get a base Support collection instance from this collection.
unique ( ) : Collection Return only unique items from the collection.

Protected Methods

Method Description
getDictionary ( Collection $collection ) : array Get a dictionary keyed by primary keys.

Method Details

__call() public method

For example, you can do $collection->save('foobar' => 1) to update the 'foobar' column to 1 across all items in the collection. IMPORTANT: The return value of the method call is not returned back to you!
public __call ( string $name, array $arguments )
$name string The method to call
$arguments array The arguments to the method

add() public method

Add an item to the collection.
public add ( mixed $item ) : Collection
$item mixed
return Collection

contains() public method

Determine if a key exists in the collection.
public contains ( mixed $key ) : boolean
$key mixed
return boolean

diff() public method

Diff the collection with the given items.
public diff ( Collection | array $collection ) : Collection
$collection FOF30\Utils\Collection | array
return FOF30\Utils\Collection

fetch() public method

Fetch a nested element of the collection.
public fetch ( string $key ) : Collection
$key string
return Collection

find() public method

Find a model in the collection by key.
public find ( mixed $key, mixed $default = null ) : DataModel
$key mixed
$default mixed
return FOF30\Model\DataModel

getDictionary() protected method

Get a dictionary keyed by primary keys.
protected getDictionary ( Collection $collection ) : array
$collection FOF30\Utils\Collection
return array

intersect() public method

Intersect the collection with the given items.
public intersect ( Collection | array $collection ) : Collection
$collection FOF30\Utils\Collection | array
return Collection

max() public method

Get the max value of a given key.
public max ( string $key ) : mixed
$key string
return mixed

merge() public method

Merge the collection with the given items.
public merge ( Collection | array $collection ) : Collection
$collection FOF30\Utils\Collection | array
return FOF30\Utils\Collection

min() public method

Get the min value of a given key.
public min ( string $key ) : mixed
$key string
return mixed

modelKeys() public method

Get the array of primary keys
public modelKeys ( ) : array
return array

removeById() public method

Remove an item in the collection by key
public removeById ( mixed $key ) : void
$key mixed
return void

toBase() public method

Get a base Support collection instance from this collection.
public toBase ( ) : Collection
return FOF30\Utils\Collection

unique() public method

Return only unique items from the collection.
public unique ( ) : Collection
return FOF30\Utils\Collection