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 ( e97398...0d97b3 )
by Benjamin
02:39
created

Request   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
eloc 33
dl 0
loc 50
ccs 24
cts 27
cp 0.8889
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 4
A createFromGlobals() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lib\Http;
6
7
use GuzzleHttp\Psr7\Request as BaseRequest;
8
use Psr\Http\Message\RequestInterface;
9
10
class Request extends BaseRequest
11
{
12
    const METHOD_HEAD = 'HEAD';
13
    const METHOD_GET = 'GET';
14
    const METHOD_POST = 'POST';
15
16
    protected $query;
17
    protected $request;
18
    protected $cookie;
19
    protected $server;
20
    protected $files;
21
22 4
    public function __construct(array $query = [], array $request = [], array $cookie = [], array $server = [], array $files = [])
23
    {
24 4
        $this->query = new ParamCollection($query);
25 4
        $this->request = new ParamCollection($request);
26 4
        $this->cookie = new ParamCollection($cookie);
27 4
        $this->server = new ServerCollection($server);
28 4
        $this->files = new ParamCollection($files);
29
30 4
        $method = $this->server->has('REQUEST_METHOD') ? $this->server->get('REQUEST_METHOD') : 'GET';
31
32 4
        $requestUri = '/';
33 4
        if ($this->server->has('REQUEST_URI')) {
34 1
            $requestUri = $this->server->get('REQUEST_URI');
35 3
        } elseif ($this->server->has('ORIG_PATH_INFO')) {
36
            $requestUri = $this->server->get('ORIG_PATH_INFO');
37
            $this->server->set('REQUEST_URI', $requestUri);
38
        }
39
40 4
        $version = $this->server->has('SERVER_PROTOCOL') ?? mb_substr($this->server->get('SERVER_PROTOCOL'), -3) ?? '1.1';
41
42 4
        parent::__construct($method, $requestUri, $this->server->getHeaders(), http_build_query($this->request->all()), $version);
43 4
    }
44
45 1
    public static function createFromGlobals(): RequestInterface
46
    {
47 1
        $datas = [$_GET, $_POST, $_COOKIE];
48 1
        foreach ($datas as &$array) {
49
            array_walk($array, function ($value) {
50
                htmlspecialchars($value);
51 1
            });
52
        }
53
54 1
        return new self(
55 1
            $_GET,
56 1
            $_POST,
57 1
            $_COOKIE,
58 1
            $_SERVER,
59 1
            $_FILES
60
        );
61
    }
62
}
63