InterruptibleProcessor::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 3
b 0
f 0
nc 3
nop 2
dl 0
loc 13
ccs 7
cts 7
cp 1
crap 3
rs 10
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