class EagerCursor implements CursorInterface (View source)

EagerCursor wraps a Cursor instance and fetches all of its results upon initialization.

Properties

protected CursorInterface $cursor The Cursor instance being wrapped.
protected array $data The Cursor results.
protected boolean $initialized Whether the internal data has been initialized.

Methods

__construct(CursorInterface $cursor)

Constructor.

count()

No description

current()

No description

getCursor()

Return the wrapped Cursor.

array|object|null
getSingleResult()

No description

initialize()

Initialize the internal data by converting the Cursor to an array.

boolean
isInitialized()

Return whether the internal data has been initialized.

key()

No description

next()

No description

rewind()

No description

array
toArray()

No description

valid()

No description

$this
addOption(string $key, mixed $value)

Wrapper method for MongoCursor::addOption().

$this
batchSize(integer $num)

Wrapper method for MongoCursor::batchSize().

boolean
dead()

Wrapper method for MongoCursor::dead().

array
explain()

Wrapper method for MongoCursor::explain().

$this
fields(array $f)

Wrapper method for MongoCursor::fields().

getCollection()

Return the collection for this cursor.

array
getFields()

Return the selected fields (projection).

array|null
getNext()

Wrapper method for MongoCursor::getNext().

array
getQuery()

Return the query criteria.

array
getReadPreference()

Wrapper method for MongoCursor::getReadPreference().

$this
setReadPreference(string $readPreference, array $tags = null)

Set the read preference.

boolean
getUseIdentifierKeys()

Return whether the document's "_id" value is used as its iteration key.

$this
setUseIdentifierKeys(boolean $useIdentifierKeys)

Set whether to use the document's "_id" value as its iteration key.

boolean
hasNext()

Wrapper method for MongoCursor::hasNext().

$this
hint(array|string $keyPattern)

Wrapper method for MongoCursor::hint().

$this
immortal(boolean $liveForever = true)

Wrapper method for MongoCursor::immortal().

array
info()

Wrapper method for MongoCursor::info().

$this
limit(integer $num)

Wrapper method for MongoCursor::limit().

maxTimeMS($ms)

{@inheritdoc}

recreate()

Recreates the internal MongoCursor.

reset()

Wrapper method for MongoCursor::reset().

$this
skip(integer $num)

Wrapper method for MongoCursor::skip().

$this
slaveOkay(boolean $ok = true)

Wrapper method for MongoCursor::slaveOkay().

$this
snapshot()

Wrapper method for MongoCursor::snapshot().

$this
sort(array $fields)

Wrapper method for MongoCursor::sort().

$this
tailable(boolean $tail = true)

Wrapper method for MongoCursor::tailable().

$this
timeout(integer $ms)

Wrapper method for MongoCursor::timeout().

Details

__construct(CursorInterface $cursor)

Constructor.

Parameters

CursorInterface $cursor

CursorInterface getCursor()

Return the wrapped Cursor.

Return Value

CursorInterface

array|object|null getSingleResult()

Return Value

array|object|null

See also

Iterator::getSingleResult

initialize()

Initialize the internal data by converting the Cursor to an array.

boolean isInitialized()

Return whether the internal data has been initialized.

Return Value

boolean

array toArray()

Return Value

array

See also

Iterator::toArray

$this addOption(string $key, mixed $value)

Wrapper method for MongoCursor::addOption().

Parameters

string $key
mixed $value

Return Value

$this

$this batchSize(integer $num)

Wrapper method for MongoCursor::batchSize().

Parameters

integer $num

Return Value

$this

boolean dead()

Wrapper method for MongoCursor::dead().

Return Value

boolean

array explain()

Wrapper method for MongoCursor::explain().

Return Value

array

$this fields(array $f)

Wrapper method for MongoCursor::fields().

Parameters

array $f Fields to return (or not return).

Return Value

$this

Collection getCollection()

Return the collection for this cursor.

Return Value

Collection

array getFields()

Return the selected fields (projection).

Return Value

array

array|null getNext()

Wrapper method for MongoCursor::getNext().

Return Value

array|null

array getQuery()

Return the query criteria.

Return Value

array

array getReadPreference()

Wrapper method for MongoCursor::getReadPreference().

Return Value

array

$this setReadPreference(string $readPreference, array $tags = null)

Set the read preference.

Parameters

string $readPreference
array $tags

Return Value

$this

boolean getUseIdentifierKeys()

Return whether the document's "_id" value is used as its iteration key.

Return Value

boolean

$this setUseIdentifierKeys(boolean $useIdentifierKeys)

Set whether to use the document's "_id" value as its iteration key.

Parameters

boolean $useIdentifierKeys

Return Value

$this

boolean hasNext()

Wrapper method for MongoCursor::hasNext().

Return Value

boolean

$this hint(array|string $keyPattern)

Wrapper method for MongoCursor::hint().

Parameters

array|string $keyPattern

Return Value

$this

$this immortal(boolean $liveForever = true)

Wrapper method for MongoCursor::immortal().

Parameters

boolean $liveForever

Return Value

$this

array info()

Wrapper method for MongoCursor::info().

Return Value

array

$this limit(integer $num)

Wrapper method for MongoCursor::limit().

Parameters

integer $num

Return Value

$this

maxTimeMS($ms)

{@inheritdoc}

Parameters

$ms

recreate()

Recreates the internal MongoCursor.

reset()

Wrapper method for MongoCursor::reset().

$this skip(integer $num)

Wrapper method for MongoCursor::skip().

Parameters

integer $num

Return Value

$this

$this slaveOkay(boolean $ok = true)

Wrapper method for MongoCursor::slaveOkay().

Parameters

boolean $ok

Return Value

$this

$this snapshot()

Wrapper method for MongoCursor::snapshot().

Return Value

$this

$this sort(array $fields)

Wrapper method for MongoCursor::sort().

Parameters

array $fields

Return Value

$this

$this tailable(boolean $tail = true)

Wrapper method for MongoCursor::tailable().

Parameters

boolean $tail

Return Value

$this

$this timeout(integer $ms)

Wrapper method for MongoCursor::timeout().

Parameters

integer $ms

Return Value

$this