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

MapIterator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A current() 0 4 1
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