Passed
Push — master ( 9b8457...f05bc0 )
by Alexander
01:49
created

Chain   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A next() 0 7 2
A __construct() 0 3 1
1
<?php
2
3
namespace alkemann\h2l;
4
5
class Chain
6
{
7
    private $chain;
8
9
    public function __construct(array $chained_callable = [])
10
    {
11
        $this->chain = $chained_callable;
12
    }
13
14
    public function next(Request $request): ?Response
15
    {
16
        if (empty($this->chain)) {
17
            throw new exceptions\EmptyChainError;
18
        }
19
        $next = array_shift($this->chain);
20
        return $next($request, $this);
21
    }
22
}
23