mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
0f0c6c4fa6
Change-Id: I87fa703da9e7725370d72c58fc40eb204a309e67
26 lines
573 B
PHP
26 lines
573 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Notifications\Iterator;
|
|
|
|
use Iterator;
|
|
use IteratorDecorator;
|
|
|
|
/**
|
|
* Applies a callback to all values returned from the iterator
|
|
*/
|
|
class CallbackIterator extends IteratorDecorator {
|
|
/** @var callable */
|
|
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() );
|
|
}
|
|
}
|
|
|
|
class_alias( CallbackIterator::class, 'EchoCallbackIterator' );
|