PHP Class Spot\Entity\Collection

Inheritance: implements Iterator, implements Countable, implements ArrayAccess
Exibir arquivo Open project: vlucas/spot Class Usage Examples

Protected Properties

Property Type Description
$_entityName
$_results
$_resultsIdentities

Public Methods

Method Description
__construct ( array $results = [], array $resultsIdentities = [], $entityName = null ) Constructor function
__toString ( ) Provides a string representation of the class Brackets contain the number of elements contained in the collection
add ( object $entity ) Add a single entity to the collection
count ( ) Get a count of all the records in the result set
current ( ) ----------------------------------------------
entityName ( )
filter ( $func ) : mixed Runs a function on every object in the query, returning an array containing every object for which the function returns true.
first ( ) : The Returns first result in set
key ( )
map ( $func ) : mixed Runs a function on every object in the query, returning the resulting array
merge ( Collection $collection, $onlyUnique = true ) Merge another collection into this collections set of entities This will only add entitys that don't already exist in the current collection
next ( )
offsetExists ( $key ) ----------------------------------------------
offsetGet ( $key )
offsetSet ( $key, $value )
offsetUnset ( $key )
rewind ( )
run ( $callback ) Run a function on the set of entities
toArray ( mixed $keyColumn = null, mixed $valueColumn = null ) : array Return an array representation of the Collection.
valid ( )

Method Details

__construct() public method

Constructor function
public __construct ( array $results = [], array $resultsIdentities = [], $entityName = null )
$results array Array of pre-loaded Spot_Entity objects or Iterator that will fetch them lazily
$resultsIdentities array Array of key values for given result set primary key

__toString() public method

Provides a string representation of the class Brackets contain the number of elements contained in the collection
public __toString ( )

add() public method

Add a single entity to the collection
public add ( object $entity )
$entity object to add

count() public method

Get a count of all the records in the result set
public count ( )

current() public method

----------------------------------------------
public current ( )

entityName() public method

public entityName ( )

filter() public method

Runs a function on every object in the query, returning an array containing every object for which the function returns true.
public filter ( $func ) : mixed
return mixed An array of Entity objects

first() public method

Returns first result in set
public first ( ) : The
return The first result in the set

key() public method

public key ( )

map() public method

Runs a function on every object in the query, returning the resulting array
public map ( $func ) : mixed
return mixed An array containing the result of running the passed function on each member of the collect

merge() public method

Merge another collection into this collections set of entities This will only add entitys that don't already exist in the current collection
public merge ( Collection $collection, $onlyUnique = true )
$collection Collection

next() public method

public next ( )

offsetExists() public method

----------------------------------------------
public offsetExists ( $key )

offsetGet() public method

public offsetGet ( $key )

offsetSet() public method

public offsetSet ( $key, $value )

offsetUnset() public method

public offsetUnset ( $key )

rewind() public method

public rewind ( )

run() public method

Run a function on the set of entities
public run ( $callback )

toArray() public method

Return an array representation of the Collection.
public toArray ( mixed $keyColumn = null, mixed $valueColumn = null ) : array
$keyColumn mixed
$valueColumn mixed
return array If $keyColumn and $valueColumn are not set, or are both null then this will return the array of entity objects

valid() public method

public valid ( )

Property Details

$_entityName protected_oe property

protected $_entityName

$_results protected_oe property

protected $_results

$_resultsIdentities protected_oe property

protected $_resultsIdentities