Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
75.00% covered (warning)
75.00%
3 / 4
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
CallbackIterator
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 current
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Extension\Notifications\Iterator;
4
5use Iterator;
6use IteratorDecorator;
7
8/**
9 * Applies a callback to all values returned from the iterator
10 */
11class CallbackIterator extends IteratorDecorator {
12    /** @var callable */
13    protected $callable;
14
15    public function __construct( Iterator $iterator, $callable ) {
16        parent::__construct( $iterator );
17        $this->callable = $callable;
18    }
19
20    public function current() {
21        return call_user_func( $this->callable, $this->iterator->current() );
22    }
23}
24
25class_alias( CallbackIterator::class, 'EchoCallbackIterator' );