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 ( 0a41a9...718635 )
by Steeven
03:33 queued 11s
created

Csrf   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 7 4
1
<?php
2
/**
3
 * This file is part of the O2System Reactor 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\Middleware;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Psr\Http\Message\ServerRequestInterface;
19
use O2System\Psr\Http\Server\RequestHandlerInterface;
20
21
/**
22
 * Class Csrf
23
 *
24
 * @package O2System\Reactor\Http\Middleware
25
 */
26
class Csrf implements RequestHandlerInterface
27
{
28
    /**
29
     * Csrf::handle
30
     *
31
     * Handles a request and produces a response
32
     *
33
     * May call other collaborating code to generate the response.
34
     *
35
     * @param \O2System\Psr\Http\Message\ServerRequestInterface $request
36
     */
37
    public function handle(ServerRequestInterface $request)
38
    {
39
        if (services()->has('csrfProtection')) {
40
            if (hash_equals(input()->server('REQUEST_METHOD'), 'POST')) {
41
                if ( ! services()->get('csrfProtection')->verify()) {
42
                    output()->sendError(403, [
43
                        'message' => language()->getLine('403_INVALID_CSRF'),
44
                    ]);
45
                }
46
            }
47
        }
48
    }
49
}