MapIterator   A
last analyzed

Coupling/Cohesion

Components 1
Dependencies 0

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A current() 0 4 1
1
<?php
2
/**
3
* This file is part of the League.csv library
4
*
5
* @license http://opensource.org/licenses/MIT
6
* @link https://github.com/thephpleague/csv/
7
* @version 9.0.0
8
* @package League.csv
9
*
10
* For the full copyright and license information, please view the LICENSE
11
* file that was distributed with this source code.
12
*/
13
declare(strict_types=1);
14
15
namespace League\Csv;
16
17
use IteratorIterator;
18
use Traversable;
19
20
/**
21
 * Map value from an iterator before yielding
22
 *
23
 * @package  League.csv
24
 * @since    3.3.0
25
 * @author   Ignace Nyamagana Butera <[email protected]>
26
 * @internal used internally to modify CSV content
27
 *
28
 */
29
class MapIterator extends IteratorIterator
30
{
31
    /**
32
     * The callback to apply on all InnerIterator current value
33
     *
34
     * @var callable
35
     */
36
    protected $callable;
37
38
    /**
39
     * The Constructor
40
     *
41
     * @param Traversable $iterator
42
     * @param callable    $callable
43
     */
44 14
    public function __construct(Traversable $iterator, callable $callable)
45
    {
46 14
        parent::__construct($iterator);
47 14
        $this->callable = $callable;
48 14
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53 6
    public function current()
54
    {
55 6
        return ($this->callable)(parent::current(), $this->key());
56
    }
57
}
58