PHP Class Jyxo\Spl\MapIterator

Supports iteration over both \Traversable and array.
Author: Jakub Tománek
Inheritance: implements Countable, implements Jyxo\Spl\ArrayCopy, implements OuterIterator, implements SeekableIterator
Datei anzeigen Open project: jyxo/php

Public Methods

Method Description
__construct ( array | Iterator | IteratorAggregate $data, callable $map ) Constructor.
count ( ) : integer Returns count of source data.
current ( ) : mixed Returns current data.
getInnerIterator ( ) : Iterator Returns inner iterator (works even when constructed with array data)
key ( ) : integer Returns current key.
next ( ) Advances the internal pointer.
rewind ( ) Rewinds the iterator to the beginning.
seek ( integer $position ) Seeks to defined position. Does NOT throw {@link \OutOfBoundsException}.
toArray ( ) : array Returns all data as an array.
valid ( ) : boolean Returns if current pointer position is valid.

Private Methods

Method Description
map ( mixed $item ) : mixed Converts source data to result using a callback function.

Method Details

__construct() public method

Constructor.
public __construct ( array | Iterator | IteratorAggregate $data, callable $map )
$data array | Iterator | IteratorAggregate Source data
$map callable Applied callback or closure

count() public method

Returns count of source data.
public count ( ) : integer
return integer

current() public method

Returns current data.
public current ( ) : mixed
return mixed

getInnerIterator() public method

Returns inner iterator (works even when constructed with array data)
public getInnerIterator ( ) : Iterator
return Iterator

key() public method

Returns current key.
public key ( ) : integer
return integer

next() public method

Advances the internal pointer.
public next ( )

rewind() public method

Rewinds the iterator to the beginning.
public rewind ( )

seek() public method

Seeks to defined position. Does NOT throw {@link \OutOfBoundsException}.
public seek ( integer $position )
$position integer New position

toArray() public method

Returns all data as an array.
public toArray ( ) : array
return array

valid() public method

Returns if current pointer position is valid.
public valid ( ) : boolean
return boolean