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.
Passed
Push — master ( 86dce3...98cf71 )
by Nur
02:40
created

Middleware   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 57
rs 10
c 0
b 0
f 0
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A process() 0 3 1
A validate() 0 7 2
A run() 0 8 3
1
<?php
2
/**
3
 * This file is part of the O2System PHP 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\Reactor\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\Psr\Patterns\Structural\Provider\AbstractProvider;
22
use O2System\Psr\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
    public function __construct()
34
    {
35
        $this->register(new Middleware\Environment(), 'environment');
36
        $this->register(new Middleware\Maintenance(), 'maintenance');
37
    }
38
39
    // ------------------------------------------------------------------------
40
41
    /**
42
     * Middleware::run
43
     *
44
     * @return void
45
     */
46
    public function run()
47
    {
48
        if ($this->count()) {
49
50
            $request = server_request();
51
52
            foreach ($this->registry as $offset => $handler) {
53
                $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\Reactor\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

53
                $this->process(/** @scrutinizer ignore-type */ $request, $handler);
Loading history...
54
            }
55
        }
56
    }
57
58
    /**
59
     * Process an incoming server request
60
     *
61
     * Processes an incoming server request in order to produce a response.
62
     * If unable to produce the response itself, it may delegate to the provided
63
     * request handler to do so.
64
     */
65
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler)
66
    {
67
        $handler->handle($request);
68
    }
69
70
    // ------------------------------------------------------------------------
71
72
    /**
73
     * Middleware::validate
74
     *
75
     * @param mixed $handler
76
     *
77
     * @return bool
78
     */
79
    public function validate($handler)
80
    {
81
        if ($handler instanceof RequestHandlerInterface) {
82
            return true;
83
        }
84
85
        return false;
86
    }
87
}