Completed
Push — master ( ecd0f8...3ad52b )
by ignace nyamagana
15:08
created

MapIterator::current()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * League.Csv (https://csv.thephpleague.com).
5
 *
6
 * @author  Ignace Nyamagana Butera <[email protected]>
7
 * @license https://github.com/thephpleague/csv/blob/master/LICENSE (MIT License)
8
 * @version 9.1.5
9
 * @link    https://github.com/thephpleague/csv
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
declare(strict_types=1);
16
17
namespace League\Csv;
18
19
use IteratorIterator;
20
use Traversable;
21
22
/**
23
 * Map value from an iterator before yielding.
24
 *
25
 * @package  League.csv
26
 * @since    3.3.0
27
 * @author   Ignace Nyamagana Butera <[email protected]>
28
 * @internal used internally to modify CSV content
29
 */
30
class MapIterator extends IteratorIterator
31
{
32
    /**
33
     * The callback to apply on all InnerIterator current value.
34
     *
35
     * @var callable
36
     */
37
    protected $callable;
38
39
    /**
40
     * New instance.
41
     */
42
    public function __construct(Traversable $iterator, callable $callable)
43 14
    {
44
        parent::__construct($iterator);
45 14
        $this->callable = $callable;
46 14
    }
47 14
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function current()
52 6
    {
53
        return ($this->callable)(parent::current(), $this->key());
54 6
    }
55
}
56