Middleware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 8 1
1
<?php
2
/**
3
 * UrlHelper
4
 *
5
 * PHP version 5
6
 *
7
 * Copyright (C) 2016 Jake Johns
8
 *
9
 * This software may be modified and distributed under the terms
10
 * of the MIT license.  See the LICENSE file for details.
11
 *
12
 * @category  Middleware
13
 * @package   Jnjxp\UrlHelper
14
 * @author    Jake Johns <[email protected]>
15
 * @copyright 2016 Jake Johns
16
 * @license   http://jnj.mit-license.org/2016 MIT License
17
 * @link      http://jakejohns.net
18
 */
19
20
namespace Jnjxp\UrlHelper;
21
22
use Psr\Http\Message\ResponseInterface as Response;
23
use Psr\Http\Message\ServerRequestInterface as Request;
24
25
/**
26
 * Middleware
27
 *
28
 * @category Middleware
29
 * @package  Jnjxp\UrlHelper
30
 * @author   Jake Johns <[email protected]>
31
 * @license  http://jnj.mit-license.org/ MIT License
32
 * @link     http://jakejohns.net
33
 */
34
class Middleware
35
{
36
    /**
37
     * Helper
38
     *
39
     * @var UrlHelper
40
     *
41
     * @access protected
42
     */
43
    protected $helper;
44
45
    /**
46
     * __construct
47
     *
48
     * @param UrlHelper $helper url helper
49
     *
50
     * @access public
51
     */
52 2
    public function __construct(UrlHelper $helper)
53
    {
54 2
        $this->helper = $helper;
55 2
    }
56
57
    /**
58
     * __invoke
59
     *
60
     * @param Request  $request  Request
61
     * @param Response $response Response
62
     * @param callable $next     next callable
63
     *
64
     * @return Response
65
     *
66
     * @access public
67
     */
68 1
    public function __invoke(
69
        Request $request,
70
        Response $response,
71
        callable $next
72
    ) {
73 1
        $this->helper->setRequest($request);
74 1
        return $next($request, $response);
75
    }
76
}
77