Passed
Push — master ( c0f6da...b424db )
by Jelmer
04:57
created

Delegate   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 21
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A next() 0 10 2
1
<?php declare(strict_types = 1);
2
3
namespace jschreuder\Middle;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Psr\Http\Message\ServerRequestInterface;
7
8
class Delegate implements DelegateInterface
9
{
10
    /** @var  \SplStack */
11
    private $stack;
12
13 3
    public function __construct(\SplStack $stack)
14
    {
15 3
        $this->stack = $stack;
16 3
    }
17
18 3
    public function next(ServerRequestInterface $request) : ResponseInterface
19
    {
20 3
        if ($this->stack->count() === 0) {
21 1
            throw new \RuntimeException('No more middleware\'s to call on.');
22
        }
23
24
        /** @var  HttpMiddlewareInterface $next */
25 3
        $next = $this->stack->pop();
26 3
        return $next->process($request, $this);
27
    }
28
}
29