Stage   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 38
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 2
A __construct() 0 4 1
1
<?php
2
/**
3
 * @author: RunnerLee
4
 * @email: [email protected]
5
 * @time: 2018-12
6
 */
7
8
namespace Runner\Pipeline;
9
10
use Runner\Pipeline\Contracts\Stage as StageInterface;
11
12
class Stage implements StageInterface
13
{
14
    /**
15
     * @var callable
16
     */
17
    protected $callback;
18
19
    /**
20
     * @var Stage|null
21
     */
22
    protected $next;
23
24
    /**
25
     * Stage constructor.
26
     *
27
     * @param $callback
28
     * @param Stage|null $next
29
     */
30 1
    public function __construct($callback, self $next = null)
31
    {
32 1
        $this->callback = $callback;
33 1
        $this->next = $next;
34 1
    }
35
36
    /**
37
     * @param $payload
38
     *
39
     * @return mixed
40
     */
41 1
    public function handle($payload)
42
    {
43
        // destination callback (without next stage)
44 1
        if (is_null($this->next)) {
45 1
            return call_user_func($this->callback, $payload);
46
        }
47
48 1
        return call_user_func($this->callback, $payload, function ($payload) {
49 1
            return $this->next->handle($payload);
0 ignored issues
show
Bug introduced by
The method handle() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
            return $this->next->/** @scrutinizer ignore-call */ handle($payload);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50 1
        });
51
    }
52
}
53