PHP Interface Pinq\ITraversable

Query calls must be immutable and return a new instance with every query call. Queries should also be executed lazily upon iteration.
Author: Elliot Levin ([email protected])
Inheritance: extends pinq\IAggregatable, extends IteratorAggregate, extends ArrayAccess
Show file Open project: timetoogo/pinq Interface Usage Examples

Public Methods

Method Description
append ( array | Traversable $values ) : pinq\ITraversable Returns values from the original and supplied values, keys will be reindexed.
asArray ( ) : array Returns the values as an array.
asCollection ( ) : pinq\ICollection Returns the values as a collection.
asTraversable ( ) : pinq\ITraversable Returns the values as a traversable.
contains ( mixed $value ) : boolean Returns whether the supplied value is contained within the aggregate
difference ( array | Traversable $values ) : pinq\ITraversable Returns unique values from the original not present in the supplied values.
except ( array | Traversable $values ) : pinq\ITraversable Returns values all values from the original not present in the supplied values.
first ( ) : mixed Returns the first value, null if empty
getIterator ( ) : Traversable Returns an array compatible iterator for the elements.
getIteratorScheme ( ) : Pinq\Iterators\IIteratorScheme Returns the underlying iterator scheme used by the implementation.
getSource ( ) : pinq\ITraversable Returns the source traversable or itself if the current traversable is the source.
getTrueIterator ( ) : Traversable Returns an iterator for all the elements.
groupBy ( callable $function ) : pinq\ITraversable Groups values according the supplied function. (Uses strict equality '===') The values will be grouped into instances of the traversable.
groupJoin ( array | Traversable $values ) : Pinq\Interfaces\IJoiningOnTraversable Matches the values with the supplied values according to the supplied filter, groups the the joined values for every original and then maps into as according to the supplied function.
indexBy ( callable $function ) : pinq\ITraversable Index the values according to the supplied mapping function.
intersect ( array | Traversable $values ) : pinq\ITraversable Returns unique values the are present in the original and supplied values.
isSource ( ) : boolean Returns whether the traversable is the source of the elements.
iterate ( callable $function ) : void Iterates the elements with the supplied function.
join ( array | Traversable $values ) : Pinq\Interfaces\IJoiningOnTraversable Matches the values with the supplied values according to the supplied filter then maps the results into as according to the supplied function.
keys ( ) : pinq\ITraversable Selects the keys as the values (indexed by their 0-based position).
last ( ) : mixed Returns the last value, null if empty
orderBy ( callable $function, integer $direction ) : Pinq\Interfaces\IOrderedTraversable Orders the values mapped from the supplied function according the supplied direction.
orderByAscending ( callable $function ) : Pinq\Interfaces\IOrderedTraversable Orders the values mapped from the supplied function ascendingly Example function:
orderByDescending ( callable $function ) : Pinq\Interfaces\IOrderedTraversable Orders the values mapped from the supplied function descendingly Example expression function:
reindex ( ) : pinq\ITraversable Indexes the values by their 0-based position.
select ( callable $function ) : pinq\ITraversable Returns the values mapped by the supplied function.
selectMany ( callable $function ) : pinq\ITraversable Returns the values mapped by the supplied function and then flattens the values into a single traversable. Keys will be reindexed.
skip ( integer $amount ) : pinq\ITraversable Skip the amount of values from the start.
slice ( integer $start, integer | null $amount ) : pinq\ITraversable Retrieve a slice of the values.
take ( integer | null $amount ) : pinq\ITraversable Limits the amount of values by the supplied amount
union ( array | Traversable $values ) : pinq\ITraversable Returns unique results present in both the original and supplied values, keys will be reindexed.
unique ( ) : pinq\ITraversable Only return unique values. (Uses strict equality '===')
where ( callable $predicate ) : pinq\ITraversable Filters the values by a supplied predicate.
whereIn ( array | Traversable $values ) : pinq\ITraversable Returns all values from the original present in the supplied values.

Method Details

append() public method

Returns values from the original and supplied values, keys will be reindexed.
public append ( array | Traversable $values ) : pinq\ITraversable
$values array | Traversable The values to append
return pinq\ITraversable

asArray() public method

Only valid array keys (strings or integers) will be used, all others will be reindexed numerically.
public asArray ( ) : array
return array

asCollection() public method

The following queries will be performed in memory.
public asCollection ( ) : pinq\ICollection
return pinq\ICollection

asTraversable() public method

The following queries will be performed in memory.
public asTraversable ( ) : pinq\ITraversable
return pinq\ITraversable

contains() public method

Returns whether the supplied value is contained within the aggregate
public contains ( mixed $value ) : boolean
$value mixed The value to check for
return boolean

difference() public method

(Uses strict equality '===')
public difference ( array | Traversable $values ) : pinq\ITraversable
$values array | Traversable The values to remove
return pinq\ITraversable

except() public method

(Uses strict equality '===')
public except ( array | Traversable $values ) : pinq\ITraversable
$values array | Traversable The values to union
return pinq\ITraversable

first() public method

Returns the first value, null if empty
public first ( ) : mixed
return mixed The first value

getIterator() public method

Non string or integer keys will be numerically reindexed.
public getIterator ( ) : Traversable
return Traversable

getIteratorScheme() public method

Returns the underlying iterator scheme used by the implementation.
public getIteratorScheme ( ) : Pinq\Iterators\IIteratorScheme
return Pinq\Iterators\IIteratorScheme

getSource() public method

Returns the source traversable or itself if the current traversable is the source.
public getSource ( ) : pinq\ITraversable
return pinq\ITraversable

getTrueIterator() public method

All keys types will remain unaltered.
public getTrueIterator ( ) : Traversable
return Traversable

groupBy() public method

This will implicitly index each group by the group key returned from the supplied function.
public groupBy ( callable $function ) : pinq\ITraversable
$function callable The grouping function
return pinq\ITraversable

groupJoin() public method

Matches the values with the supplied values according to the supplied filter, groups the the joined values for every original and then maps into as according to the supplied function.
public groupJoin ( array | Traversable $values ) : Pinq\Interfaces\IJoiningOnTraversable
$values array | Traversable
return Pinq\Interfaces\IJoiningOnTraversable

indexBy() public method

All duplicate indexes will be associated with the first value for that index.
public indexBy ( callable $function ) : pinq\ITraversable
$function callable The projection function
return pinq\ITraversable

intersect() public method

(Uses strict equality '===')
public intersect ( array | Traversable $values ) : pinq\ITraversable
$values array | Traversable The values to intersect with
return pinq\ITraversable

isSource() public method

Returns whether the traversable is the source of the elements.
public isSource ( ) : boolean
return boolean

iterate() public method

Returning false will break the iteration loop.
public iterate ( callable $function ) : void
$function callable The iteration function, parameters are passed as ($value, $key)
return void

join() public method

Matches the values with the supplied values according to the supplied filter then maps the results into as according to the supplied function.
public join ( array | Traversable $values ) : Pinq\Interfaces\IJoiningOnTraversable
$values array | Traversable
return Pinq\Interfaces\IJoiningOnTraversable

keys() public method

Selects the keys as the values (indexed by their 0-based position).
public keys ( ) : pinq\ITraversable
return pinq\ITraversable

last() public method

Returns the last value, null if empty
public last ( ) : mixed
return mixed The last value

orderBy() public method

Orders the values mapped from the supplied function according the supplied direction.
public orderBy ( callable $function, integer $direction ) : Pinq\Interfaces\IOrderedTraversable
$function callable The projection function
$direction integer
return Pinq\Interfaces\IOrderedTraversable

orderByAscending() public method

Orders the values mapped from the supplied function ascendingly Example function:
public orderByAscending ( callable $function ) : Pinq\Interfaces\IOrderedTraversable
$function callable The mapping function
return Pinq\Interfaces\IOrderedTraversable

orderByDescending() public method

Orders the values mapped from the supplied function descendingly Example expression function:
public orderByDescending ( callable $function ) : Pinq\Interfaces\IOrderedTraversable
$function callable The mapping function
return Pinq\Interfaces\IOrderedTraversable

reindex() public method

Indexes the values by their 0-based position.
public reindex ( ) : pinq\ITraversable
return pinq\ITraversable

select() public method

Returns the values mapped by the supplied function.
public select ( callable $function ) : pinq\ITraversable
$function callable The function returning the data to select
return pinq\ITraversable

selectMany() public method

Returns the values mapped by the supplied function and then flattens the values into a single traversable. Keys will be reindexed.
public selectMany ( callable $function ) : pinq\ITraversable
$function callable The function returning the data to select
return pinq\ITraversable

skip() public method

Skip the amount of values from the start.
public skip ( integer $amount ) : pinq\ITraversable
$amount integer The amount of values to skip, must be > 0
return pinq\ITraversable

slice() public method

Retrieve a slice of the values.
public slice ( integer $start, integer | null $amount ) : pinq\ITraversable
$start integer The amount of values to skip
$amount integer | null The amount of values to retrieve
return pinq\ITraversable

take() public method

Limits the amount of values by the supplied amount
public take ( integer | null $amount ) : pinq\ITraversable
$amount integer | null The amount of values to retrieve, must be > 0 or null if all
return pinq\ITraversable

union() public method

(Uses strict equality '===')
public union ( array | Traversable $values ) : pinq\ITraversable
$values array | Traversable The values to union
return pinq\ITraversable

unique() public method

Only return unique values. (Uses strict equality '===')
public unique ( ) : pinq\ITraversable
return pinq\ITraversable

where() public method

Filters the values by a supplied predicate.
public where ( callable $predicate ) : pinq\ITraversable
$predicate callable The predicate function
return pinq\ITraversable

whereIn() public method

(Uses strict equality '===')
public whereIn ( array | Traversable $values ) : pinq\ITraversable
$values array | Traversable
return pinq\ITraversable