EnumerableArray

Implements \ArrayAccess

An array-like object that implements the Enumerable trait. The EnumerableArray does only support numeric keys.

package

Default

Methods

Creates a new EnumerableArray. If an array was provided as argument, its elements will be added to the elements of the current object, but all original keys will be dropped.

__construct(array $elems = array()) 

Arguments

$elems

array

Returns one element at a time from the enumerable. When implementing this method, you should only return values using the yield keyword. Do not use the return keyword to return values from this method!

__each() 
inherited abstract

Returns true if all elements in the enumerable returns true from the callback.

all(callable $callback) : boolean
inherited

Otherwise returns false.

Arguments

$callback

callable

Response

boolean

Returns true if any elements in the enumerable returns true from the callback.

any(callable $callback) : boolean
inherited

Otherwise returns false.

Arguments

$callback

callable

Response

boolean

Adds an element to the end of the EnumerableArray.

append(mixed $elem) : null

Arguments

$elem

mixed

Response

null

Returns the number of elements in the enumerable. If a callback is provided, only those alements that return true from the callback are counted.

count(callable $callback = null) : integer
inherited

Otherwise returns false.

Arguments

$callback

callable

Response

integer

Drops a number of elemens from the enumerable and returns the remaining elements as an EnumerableArray.

drop(integer $numElems) : \Lasso3000\Enumerable\EnumerableArray
inherited

Arguments

$numElems

integer

Response

\Lasso3000\Enumerable\EnumerableArray

Drops elements until the provided callback returns true. The remaining elements are returned as an EnumerableArray.

dropWhile(callable $callback) : \Lasso3000\Enumerable\EnumerableArray
inherited

Arguments

$callback

callable

Response

\Lasso3000\Enumerable\EnumerableArray

Applies a callback on each element in the enumerable without returning any value.

each(callable $callback) : null
inherited

Arguments

$callback

callable

Response

null

Returns the first element in the enumerable that returns true from the callback.

find(callable $callback, mixed $default = null) : mixed
inherited

If no matching element can be found, the provided default is returned instead.

Arguments

$callback

callable

$default

mixed

Response

mixed

Returns all elements in the enumerable that returns true from the callback.

findAll(callable $callback) : \Lasso3000\Enumerable\EnumerableArray
inherited

Arguments

$callback

callable

Response

\Lasso3000\Enumerable\EnumerableArray

Returns the index where $needle can be found. If $needle cannot be found, null is returned.

findIndex(mixed $needle) : integer|null
inherited

$needle can be either a callable or a value.

Arguments

$needle

mixed

Response

integer|null

Applies callback to all elements in the enumerable and returns an EnumerableArray with new result.

map(callable $callback) : \Lasso3000\Enumerable\EnumerableArray
inherited

Arguments

$callback

callable

Response

\Lasso3000\Enumerable\EnumerableArray

Returns true if the provided argument is a member of the enumerable.

member(mixed $needle) : boolean
inherited

Otherwise returns false.

Arguments

$needle

mixed

Response

boolean

Returns true if no element in the enumerable returns true from the callback.

none(callable $callback) : boolean
inherited

Arguments

$callback

callable

Response

boolean

Returns whether the specified offset exists in this enumerable.

offsetExists(integer $offset) : boolean

Arguments

$offset

integer

Response

boolean

Returns the element at the provided index.

offsetGet(integer $offset) : mixed
Throws
\OutOfRangeException

Arguments

$offset

integer

Response

mixed

Sets the element at the provided index to the provided value.

offsetSet(integer $offset, mixed $value) : null
Throws
\OutOfRangeException

Arguments

$offset

integer

$value

mixed

Response

null

Unsets the element at the provided index.

offsetUnset(integer $offset) : null
Throws
\OutOfRangeException

Arguments

$offset

integer

Response

null

Returns true if exactly one element in the enumerable returns true from the callback.

one(callable $callback) : boolean
inherited

Arguments

$callback

callable

Response

boolean

Returns an EnumerableArray with two elements, one EnumerableArray with all elements in the enumerable that returns true from the callback, and one EnumerableArray with all elements in the enumerable that returns false from the callback.

partition(callable $callback) : \Lasso3000\Enumerable\EnumerableArray
inherited

Arguments

$callback

callable

Response

\Lasso3000\Enumerable\EnumerableArray

Reduces an enumerable into a single value by applying a callback to each element.

reduce(callable $callback, mixed $initialValue = null) : \Lasso3000\Enumerable\EnumerableArray
inherited

Arguments

$callback

callable

$initialValue

mixed

Response

\Lasso3000\Enumerable\EnumerableArray

Returns an EnumerableArray containing all elements in the enumerable that returns false from the callback.

reject(callable $callback) : \Lasso3000\Enumerable\EnumerableArray
inherited

Arguments

$callback

callable

Response

\Lasso3000\Enumerable\EnumerableArray

Applies a callback on each element in the enumerable in reverse order without returning any value.

reverseEach(callable $callback) : null
inherited

Arguments

$callback

callable

Response

null

Sorts the elements in the enumerable by using a callback.

sort(callable $callback) : \Lasso3000\Enumerable\EnumerableArray
inherited

Arguments

$callback

callable

Response

\Lasso3000\Enumerable\EnumerableArray

Takes a number of elemens from the enumerable and returns them as an EnumerableArray.

take(integer $numElems) : \Lasso3000\Enumerable\EnumerableArray
inherited

Arguments

$numElems

integer

Response

\Lasso3000\Enumerable\EnumerableArray

Takes elements from the enumerable until the provided callback returns false.

takeWhile(callable $callback) : \Lasso3000\Enumerable\EnumerableArray
inherited

The result is returned as an EnumerableArray.

Arguments

$callback

callable

Response

\Lasso3000\Enumerable\EnumerableArray

Returns the elements of this object as an array.

toArray() : array

Response

array

Properties

Internal storage for elements.

elems : array
var

Type(s)

array