InterruptibleProcessor::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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