Enumerating::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Arnaud LEMAIRE  <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Fp\Reducer;
13
14
class Enumerating implements Reducer
15
{
16
    use Mixin\Stateless;
17
18
    protected $next_reducer;
19
    protected $counter;
20
21 3
    public function __construct(Reducer $next_reducer, $start = 0)
22
    {
23 3
        $this->next_reducer = $next_reducer;
24 3
        $this->counter = $start;
25 3
    }
26
27 2
    public function step($result, $current)
28
    {
29 2
        $index = $this->counter++;
30
31 2
        return $this->next_reducer->step($result, [$index, $current]);
32
    }
33
}
34