InterruptibleProcessor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 3
A __construct() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace League\Pipeline;
5
6
class InterruptibleProcessor implements ProcessorInterface
7
{
8
    /**
9
     * @var callable
10
     */
11
    private $check;
12
13 4
    public function __construct(callable $check)
14
    {
15 4
        $this->check = $check;
16 4
    }
17
18 2
    public function process($payload, callable ...$stages)
19
    {
20 2
        $check = $this->check;
21
22 2
        foreach ($stages as $stage) {
23 2
            $payload = $stage($payload);
24
25 2
            if (true !== $check($payload)) {
26 2
                return $payload;
27
            }
28
        }
29
30 2
        return $payload;
31
    }
32
}
33