MiddlewareAbstract::next()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php
2
namespace Staticus\Middlewares;
3
4
use Zend\Diactoros\Response\EmptyResponse;
5
use Psr\Http\Message\ResponseInterface;
6
use Psr\Http\Message\ServerRequestInterface;
7
use Zend\Stratigility\MiddlewareInterface;
8
9
abstract class MiddlewareAbstract implements MiddlewareInterface
10
{
11
    /**
12
     * @var ServerRequestInterface
13
     */
14
    protected $request;
15
    /**
16
     * @var ResponseInterface
17
     */
18
    protected $response;
19
    /**
20
     * @var callable
21
     */
22
    protected $next;
23
24
    /**
25
     * @param ServerRequestInterface $request
26
     * @param ResponseInterface $response
27
     * @param callable|null $next
28
     * @return null|ResponseInterface
29
     * @throws \Exception
30
     */
31
    public function __invoke(
32
        ServerRequestInterface $request,
33
        ResponseInterface $response,
34
        callable $next = null
35
    )
36
    {
37
        $this->request = $request;
38
        $this->response = $response;
39
        $this->next = $next;
40
    }
41
42
    /**
43
     * @return mixed
44
     */
45
    protected function next()
46
    {
47
        $next = $this->next;
48
49
        return $next($this->request, $this->response);
50
    }
51
}
52