LazyCriteriaCollection
extends AbstractLazyCollection
in package
implements
Selectable
A lazy collection that allows a fast count when using criteria object Once count gets executed once without collection being initialized, result is cached and returned on subsequent calls until collection gets loaded, then returning the number of loaded results.
Interfaces, Classes, Traits and Enums
- Selectable
- Interface for collections that allow efficient filtering with an expression API.
Table of Contents
- $collection : Collection<string|int, mixed>
- The backed collection to use
- $criteria : Criteria
- $entityPersister : EntityPersister
- $initialized : bool
- $count : int|null
- __construct() : mixed
- add() : true
- Adds an element at the end of the collection.
- clear() : void
- Clears the collection, removing all elements.
- contains() : bool
- Do an optimized search of an element
- containsKey() : bool
- Checks whether the collection contains an element with the specified key/index.
- count() : int
- Do an efficient count on the collection
- current() : mixed
- Gets the element of the collection at the current iterator position.
- exists() : bool
- Tests for the existence of an element that satisfies the given predicate.
- filter() : Collection<string|int, mixed>
- Returns all the elements of this collection that satisfy the predicate p.
- first() : mixed
- Sets the internal iterator to the first element in the collection and returns this element.
- forAll() : bool
- Tests whether the given predicate p holds for all elements of this collection.
- get() : mixed
- Gets the element at the specified key/index.
- getIterator() : Traversable<int|string, mixed>
- {@inheritDoc}
- getKeys() : array<string|int, int>|array<string|int, string>
- Gets all keys/indices of the collection.
- getValues() : array<string|int, mixed>
- Gets all values of the collection.
- indexOf() : int|string|bool
- Gets the index/key of a given element. The comparison of two elements is strict, that means not only the value but also the type must match.
- isEmpty() : bool
- check if collection is empty without loading it
- isInitialized() : bool
- Is the lazy collection already initialized?
- key() : int|string|null
- Gets the key/index of the element at the current iterator position.
- last() : mixed
- Sets the internal iterator to the last element in the collection and returns this element.
- map() : Collection<string|int, mixed>
- Applies the given function to each element in the collection and returns a new collection with the elements returned by the function.
- matching() : Collection<string|int, mixed>
- Selects all elements from a selectable that match the expression and returns a new collection containing these elements.
- next() : mixed
- Moves the internal iterator position to the next element and returns this element.
- offsetExists() : bool
- {@inheritDoc}
- offsetGet() : mixed
- {@inheritDoc}
- offsetSet() : void
- {@inheritDoc}
- offsetUnset() : void
- {@inheritDoc}
- partition() : Collection<string|int, mixed>
- Partitions this collection in two collections according to a predicate.
- remove() : mixed
- Removes the element at the specified index from the collection.
- removeElement() : bool
- Removes the specified element from the collection, if it is found.
- set() : void
- Sets an element in the collection at the specified key/index.
- slice() : array<string|int, mixed>
- Extracts a slice of $length elements starting at position $offset from the Collection.
- toArray() : array<string|int, mixed>
- Gets a native PHP array representation of the collection.
- doInitialize() : void
- Do the initialization logic
- initialize() : void
- Initialize the collection
Properties
$collection
The backed collection to use
protected
Collection<string|int, mixed>
$collection
Tags
$criteria
protected
Criteria
$criteria
$entityPersister
protected
EntityPersister
$entityPersister
$initialized
protected
bool
$initialized
= false
$count
private
int|null
$count
Methods
__construct()
public
__construct(EntityPersister $entityPersister, Criteria $criteria) : mixed
Parameters
- $entityPersister : EntityPersister
- $criteria : Criteria
Return values
mixed —add()
Adds an element at the end of the collection.
public
add(mixed $element) : true
Parameters
- $element : mixed
-
The element to add.
Return values
true —Always TRUE.
clear()
Clears the collection, removing all elements.
public
clear() : void
Return values
void —contains()
Do an optimized search of an element
public
contains(object $element) : bool
Parameters
- $element : object
Return values
bool —containsKey()
Checks whether the collection contains an element with the specified key/index.
public
containsKey(mixed $key) : bool
Parameters
- $key : mixed
-
The key/index to check for.
Return values
bool —TRUE if the collection contains an element with the specified key/index, FALSE otherwise.
count()
Do an efficient count on the collection
public
count() : int
Return values
int —current()
Gets the element of the collection at the current iterator position.
public
current() : mixed
Return values
mixed —exists()
Tests for the existence of an element that satisfies the given predicate.
public
exists(Closure $p) : bool
Parameters
- $p : Closure
-
The predicate.
Return values
bool —TRUE if the predicate is TRUE for at least one element, FALSE otherwise.
filter()
Returns all the elements of this collection that satisfy the predicate p.
public
filter(Closure $p) : Collection<string|int, mixed>
Parameters
- $p : Closure
-
The predicate used for filtering.
Return values
Collection<string|int, mixed> —A collection with the results of the filter operation.
first()
Sets the internal iterator to the first element in the collection and returns this element.
public
first() : mixed
Return values
mixed —forAll()
Tests whether the given predicate p holds for all elements of this collection.
public
forAll(Closure $p) : bool
Parameters
- $p : Closure
-
The predicate.
Return values
bool —TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.
get()
Gets the element at the specified key/index.
public
get(mixed $key) : mixed
Parameters
- $key : mixed
-
The key/index of the element to retrieve.
Return values
mixed —getIterator()
{@inheritDoc}
public
getIterator() : Traversable<int|string, mixed>
Tags
Return values
Traversable<int|string, mixed> —getKeys()
Gets all keys/indices of the collection.
public
getKeys() : array<string|int, int>|array<string|int, string>
Return values
array<string|int, int>|array<string|int, string> —The keys/indices of the collection, in the order of the corresponding elements in the collection.
getValues()
Gets all values of the collection.
public
getValues() : array<string|int, mixed>
Return values
array<string|int, mixed> —The values of all elements in the collection, in the order they appear in the collection.
indexOf()
Gets the index/key of a given element. The comparison of two elements is strict, that means not only the value but also the type must match.
public
indexOf(mixed $element) : int|string|bool
Parameters
- $element : mixed
-
The element to search for.
Return values
int|string|bool —The key/index of the element or FALSE if the element was not found.
isEmpty()
check if collection is empty without loading it
public
isEmpty() : bool
Return values
bool —TRUE if the collection is empty, FALSE otherwise.
isInitialized()
Is the lazy collection already initialized?
public
isInitialized() : bool
Return values
bool —key()
Gets the key/index of the element at the current iterator position.
public
key() : int|string|null
Return values
int|string|null —last()
Sets the internal iterator to the last element in the collection and returns this element.
public
last() : mixed
Return values
mixed —map()
Applies the given function to each element in the collection and returns a new collection with the elements returned by the function.
public
map(Closure $func) : Collection<string|int, mixed>
Parameters
- $func : Closure
Return values
Collection<string|int, mixed> —matching()
Selects all elements from a selectable that match the expression and returns a new collection containing these elements.
public
matching(Criteria $criteria) : Collection<string|int, mixed>
Parameters
- $criteria : Criteria
Return values
Collection<string|int, mixed> —next()
Moves the internal iterator position to the next element and returns this element.
public
next() : mixed
Return values
mixed —offsetExists()
{@inheritDoc}
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Tags
Return values
bool —offsetGet()
{@inheritDoc}
public
offsetGet(int|string $offset) : mixed
Parameters
- $offset : int|string
Tags
Return values
mixed —offsetSet()
{@inheritDoc}
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Tags
Return values
void —offsetUnset()
{@inheritDoc}
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
Tags
Return values
void —partition()
Partitions this collection in two collections according to a predicate.
public
partition(Closure $p) : Collection<string|int, mixed>
Parameters
- $p : Closure
-
The predicate on which to partition.
Return values
Collection<string|int, mixed> —An array with two elements. The first element contains the collection of elements where the predicate returned TRUE, the second element contains the collection of elements where the predicate returned FALSE.
remove()
Removes the element at the specified index from the collection.
public
remove(mixed $key) : mixed
Parameters
- $key : mixed
-
The key/index of the element to remove.
Return values
mixed —The removed element or NULL, if the collection did not contain the element.
removeElement()
Removes the specified element from the collection, if it is found.
public
removeElement(mixed $element) : bool
Parameters
- $element : mixed
-
The element to remove.
Return values
bool —TRUE if this collection contained the specified element, FALSE otherwise.
set()
Sets an element in the collection at the specified key/index.
public
set(mixed $key, mixed $value) : void
Parameters
- $key : mixed
-
The key/index of the element to set.
- $value : mixed
-
The element to set.
Return values
void —slice()
Extracts a slice of $length elements starting at position $offset from the Collection.
public
slice(mixed $offset[, mixed $length = null ]) : array<string|int, mixed>
Parameters
- $offset : mixed
-
The offset to start from.
- $length : mixed = null
-
The maximum number of elements to return, or null for no limit.
Return values
array<string|int, mixed> —toArray()
Gets a native PHP array representation of the collection.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —doInitialize()
Do the initialization logic
protected
doInitialize() : void
Return values
void —initialize()
Initialize the collection
protected
initialize() : void