MiddlewareAbstract   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 43
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 1
A next() 0 6 1
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