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.

Request::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 14
nc 6
nop 5
dl 0
loc 21
rs 9.7998
c 0
b 0
f 0
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
    // @codeCoverageIgnoreStart
13
    const METHOD_HEAD = 'HEAD';
14
    const METHOD_GET = 'GET';
15
    const METHOD_POST = 'POST';
16
17
    protected $query;
18
    protected $request;
19
    protected $cookie;
20
    protected $server;
21
    protected $files;
22
23
    public function __construct(array $query = [], array $request = [], array $cookie = [], array $server = [], array $files = [])
24
    {
25
        $this->query = new ParamCollection($query);
26
        $this->request = new ParamCollection($request);
27
        $this->cookie = new ParamCollection($cookie);
28
        $this->server = new ServerCollection($server);
29
        $this->files = new ParamCollection($files);
30
31
        $method = $this->server->has('REQUEST_METHOD') ? $this->server->get('REQUEST_METHOD') : 'GET';
32
33
        $requestUri = '/';
34
        if ($this->server->has('REQUEST_URI')) {
35
            $requestUri = $this->server->get('REQUEST_URI');
36
        } elseif ($this->server->has('ORIG_PATH_INFO')) {
37
            $requestUri = $this->server->get('ORIG_PATH_INFO');
38
            $this->server->set('REQUEST_URI', $requestUri);
39
        }
40
41
        $version = $this->server->has('SERVER_PROTOCOL') ?? mb_substr($this->server->get('SERVER_PROTOCOL'), -3) ?? '1.1';
42
43
        parent::__construct($method, $requestUri, $this->server->getHeaders(), http_build_query($this->request->all()), $version);
44
    }
45
46
    public static function createFromGlobals(): RequestInterface
47
    {
48
        $datas = [$_GET, $_POST, $_COOKIE];
49
        foreach ($datas as &$array) {
50
            array_walk($array, function ($value) {
51
                htmlspecialchars($value);
52
            });
53
        }
54
55
        return new self(
56
            $_GET,
57
            $_POST,
58
            $_COOKIE,
59
            $_SERVER,
60
            $_FILES
61
        );
62
    }
63
64
    // @codeCoverageIgnoreEnd
65
}
66