2014-07-30 03:18:48 +00:00
|
|
|
<?php
|
|
|
|
|
2022-11-02 20:26:48 +00:00
|
|
|
namespace MediaWiki\Extension\Notifications\Iterator;
|
|
|
|
|
|
|
|
use Iterator;
|
|
|
|
use IteratorDecorator;
|
|
|
|
|
2014-07-30 03:18:48 +00:00
|
|
|
/**
|
|
|
|
* Applies a callback to all values returned from the iterator
|
|
|
|
*/
|
2022-11-02 20:26:48 +00:00
|
|
|
class CallbackIterator extends IteratorDecorator {
|
2020-12-16 21:31:09 +00:00
|
|
|
/** @var callable */
|
2014-07-30 03:18:48 +00:00
|
|
|
protected $callable;
|
|
|
|
|
|
|
|
public function __construct( Iterator $iterator, $callable ) {
|
|
|
|
parent::__construct( $iterator );
|
|
|
|
$this->callable = $callable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function current() {
|
|
|
|
return call_user_func( $this->callable, $this->iterator->current() );
|
|
|
|
}
|
|
|
|
}
|
2022-11-02 20:26:48 +00:00
|
|
|
|
|
|
|
class_alias( CallbackIterator::class, 'EchoCallbackIterator' );
|