InterruptibleProcessor   A
last analyzed

↳ Parent: Project

Coupling/Cohesion

Components 1
Dependencies 0

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

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