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.1.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]com>
26
 * @internal used internally to modify CSV content
27
 */
28
class MapIterator extends IteratorIterator
29
{
30
    /**
31
     * The callback to apply on all InnerIterator current value
32
     *
33
     * @var callable
34
     */
35
    protected $callable;
36
37
    /**
38
     * The Constructor
39
     *
40
     * @param Traversable $iterator
41
     * @param callable    $callable
42
     */
43 14
    public function __construct(Traversable $iterator, callable $callable)
44
    {
45 14
        parent::__construct($iterator);
46 14
        $this->callable = $callable;
47 14
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52 6
    public function current()
53
    {
54 6
        return ($this->callable)(parent::current(), $this->key());
55
    }
56
}
57