W3cubDocs

/CakePHP 3.4

Class ReplaceIterator

Creates an iterator from another iterator that will modify each of the values by converting them using a callback function.

IteratorIterator implements Iterator, Traversable, OuterIterator
Extended by Cake\Collection\Collection implements Cake\Collection\CollectionInterface, Serializable uses Cake\Collection\CollectionTrait
Extended by Cake\Collection\Iterator\ReplaceIterator

Properties summary

  • $_callback protected
    callable
    The callback function to be used to modify each of the values
  • $_innerIterator protected
    Iterator
    A reference to the internal iterator this object is wrapping.

Method Summary

  • __construct() public

    Creates an iterator from another iterator that will modify each of the values by converting them using a callback function.

  • current() public

    Returns the value returned by the callback after passing the current value in the iteration

Method Detail

__construct()source public

__construct( array|Traversable $items , callable $callback )

Creates an iterator from another iterator that will modify each of the values by converting them using a callback function.

Each time the callback is executed it will receive the value of the element in the current iteration, the key of the element and the passed $items iterator as arguments, in that order.

Parameters

array|Traversable $items
The items to be filtered.
callable $callback
Callback.

Throws

InvalidArgumentException
If passed incorrect type for items.

Overrides

Cake\Collection\Collection::__construct()

current()source public

current( )

Returns the value returned by the callback after passing the current value in the iteration

Returns

mixed

Overrides

IteratorIterator::current()

Methods inherited from Cake\Collection\Collection

__debugInfo()source public

__debugInfo( )

Returns an array that can be used to describe the internal state of this object.

Returns

array

count()source public

count( )

Throws an exception.

Issuing a count on a Collection can have many side effects, some making the Collection unusable after the count operation.

Throws

LogicException

serialize()source public

serialize( )

Returns a string representation of this object that can be used to reconstruct it

Returns

string

Implementation of

Serializable::serialize()

unserialize()source public

unserialize( string $collection )

Unserializes the passed string and rebuilds the Collection instance

Parameters

string $collection
The serialized collection

Implementation of

Serializable::unserialize()

Methods used from Cake\Collection\CollectionTrait

_unwrap()source public

_unwrap( )

append()source public

append( $items )

buffered()source public

buffered( )

Returns

Cake\Collection\Iterator\BufferedIterator

cartesianProduct()source public

cartesianProduct( callable $operation null , callable $filter null )

Returns

Cake\Collection\CollectionInterface

chunk()source public

chunk( $chunkSize )

chunkWithKeys()source public

chunkWithKeys( $chunkSize , $preserveKeys true )

combine()source public

combine( $keyPath , $valuePath , $groupPath null )

compile()source public

compile( $preserveKeys true )

contains()source public

contains( $value )

countBy()source public

countBy( $callback )

each()source public

each( callable $c )

every()source public

every( callable $c )

extract()source public

extract( $matcher )

filter()source public

filter( callable $c null )

Returns

Cake\Collection\Iterator\FilterIterator

first()source public

first( )

firstMatch()source public

firstMatch( array $conditions )

groupBy()source public

groupBy( $callback )

indexBy()source public

indexBy( $callback )

insert()source public

insert( $path , $values )

Returns

Cake\Collection\Iterator\InsertIterator

isEmpty()source public

isEmpty( )

jsonSerialize()source public

jsonSerialize( )

last()source public

last( )

listNested()source public

listNested( $dir 'desc' , $nestingKey 'children' )

Returns

Cake\Collection\Iterator\TreeIterator

map()source public

map( callable $c )

Returns

Cake\Collection\Iterator\ReplaceIterator

match()source public

match( array $conditions )

max()source public

max( $callback , $type SORT_NUMERIC )

min()source public

min( $callback , $type SORT_NUMERIC )

nest()source public

nest( $idPath , $parentPath , $nestingKey 'children' )

reduce()source public

reduce( callable $c , $zero null )

reject()source public

reject( callable $c )

Returns

Cake\Collection\Iterator\FilterIterator

sample()source public

sample( $size 10 )

shuffle()source public

shuffle( )

skip()source public

skip( $howMany )

some()source public

some( callable $c )

sortBy()source public

sortBy( $callback , $dir SORT_DESC , $type SORT_NUMERIC )

stopWhen()source public

stopWhen( $condition )

Returns

Cake\Collection\Iterator\StoppableIterator

sumOf()source public

sumOf( $matcher null )

take()source public

take( $size 1 , $from 0 )

through()source public

through( callable $handler )

toArray()source public

toArray( $preserveKeys true )

toList()source public

toList( )

transpose()source public

transpose( )

Returns

Cake\Collection\CollectionInterface

unfold()source public

unfold( callable $transformer null )

unwrap()source public

unwrap( )

zip()source public

zip( $items )

zipWith()source public

zipWith( $items , $callable )

Properties detail

$_callbacksource

protected callable

The callback function to be used to modify each of the values

$_innerIteratorsource

protected Iterator

A reference to the internal iterator this object is wrapping.

© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.4/class-Cake.Collection.Iterator.ReplaceIterator.html