GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Middleware::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Framework\Http;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Psr\Http\Message\ServerRequestInterface;
19
use O2System\Psr\Http\Server\MiddlewareInterface;
20
use O2System\Psr\Http\Server\RequestHandlerInterface;
21
use O2System\Spl\Patterns\Structural\Provider\AbstractProvider;
22
use O2System\Spl\Patterns\Structural\Provider\ValidationInterface;
23
24
/**
25
 * Class Middleware
26
 *
27
 * @package O2System
28
 */
29
class Middleware extends AbstractProvider implements
30
    ValidationInterface,
31
    MiddlewareInterface
32
{
33
    /**
34
     * Middleware::__construct
35
     */
36
    public function __construct()
37
    {
38
        $this->register(new Middleware\Environment(), 'environment');
39
        $this->register(new Middleware\Maintenance(), 'maintenance');
40
        $this->register(new Middleware\Csrf(), 'csrf');
41
        $this->register(new Middleware\SignOn(), 'sign-on');
42
        $this->register(new Middleware\Cache(), 'cache');
43
    }
44
45
    // ------------------------------------------------------------------------
46
47
    /**
48
     * Middleware::run
49
     *
50
     * @return void
51
     */
52
    public function run()
53
    {
54
        if ($this->count()) {
55
56
            $request = server_request();
57
58
            foreach ($this->registry as $offset => $handler) {
59
                $this->process($request, $handler);
0 ignored issues
show
Bug introduced by
$request of type O2System\Kernel\Http\Message\Request is incompatible with the type O2System\Psr\Http\Message\ServerRequestInterface expected by parameter $request of O2System\Framework\Http\Middleware::process(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

59
                $this->process(/** @scrutinizer ignore-type */ $request, $handler);
Loading history...
60
            }
61
        }
62
    }
63
64
    // ------------------------------------------------------------------------
65
66
    /**
67
     * Middleware::process
68
     * 
69
     * Process an incoming server request
70
     *
71
     * Processes an incoming server request in order to produce a response.
72
     * If unable to produce the response itself, it may delegate to the provided
73
     * request handler to do so.
74
     * 
75
     * @param ServerRequestInterface  $request
76
     * @param RequestHandlerInterface $handler
77
     */
78
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler)
79
    {
80
        $handler->handle($request);
81
    }
82
83
    // ------------------------------------------------------------------------
84
85
    /**
86
     * Middleware::validate
87
     * 
88
     * Validate if the handler is an instanceof RequestHandlerInterface.
89
     *
90
     * @param mixed $handler
91
     *
92
     * @return bool
93
     */
94
    public function validate($handler)
95
    {
96
        if ($handler instanceof RequestHandlerInterface) {
97
            return true;
98
        }
99
100
        return false;
101
    }
102
}