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

Chain::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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