Middleware::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 3
crap 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