ConverterStep   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 41
rs 10
c 0
b 0
f 0
ccs 13
cts 13
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A add() 0 6 1
A process() 0 8 2
1
<?php
2
3
namespace Port\Steps\Step;
4
5
use Port\Steps\Step;
6
7
/**
8
 * @author Markus Bachmann <[email protected]>
9
 */
10
class ConverterStep implements Step
11
{
12
    /**
13
     * @var callable[]
14
     */
15
    private $converters;
16
17
    /**
18
     * @param array $converters
19
     */
20 3
    public function __construct(array $converters = [])
21
    {
22 3
        foreach ($converters as $converter) {
23 1
            $this->add($converter);
24 3
        }
25 3
    }
26
27
    /**
28
     * @param callable $converter
29
     *
30
     * @return $this
31
     */
32 1
    public function add(callable $converter)
33
    {
34 1
        $this->converters[] = $converter;
35
36 1
        return $this;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 1
    public function process($item, callable $next)
43
    {
44 1
        foreach ($this->converters as $converter) {
45 1
            $item = call_user_func($converter, $item);
46 1
        }
47
48 1
        return $next($item);
49
    }
50
}
51