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.

Environment   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 118
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 52
c 1
b 0
f 0
dl 0
loc 118
rs 10
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A values() 0 3 1
A autoIncludeKey() 0 3 2
A include() 0 5 1
A __construct() 0 8 1
A data() 0 5 2
A httpKey() 0 3 1
A whitelistKey() 0 3 1
1
<?php
2
3
namespace Honeybadger;
4
5
use Honeybadger\Concerns\FiltersData;
6
7
class Environment
8
{
9
    use FiltersData;
10
11
    const KEY_WHITELIST = [
12
        'PHP_SELF',
13
        'argv',
14
        'argc',
15
        'GATEWAY_INTERFACE',
16
        'SERVER_ADDR',
17
        'SERVER_NAME',
18
        'SERVER_SOFTWARE',
19
        'SERVER_PROTOCOL',
20
        'REQUEST_METHOD',
21
        'REQUEST_TIME',
22
        'REQUEST_TIME_FLOAT',
23
        'QUERY_STRING',
24
        'DOCUMENT_ROOT',
25
        'HTTPS',
26
        'REMOTE_ADDR',
27
        'REMOTE_HOST',
28
        'REMOTE_PORT',
29
        'REMOTE_USER',
30
        'REDIRECT_REMOTE_USER',
31
        'SCRIPT_FILENAME',
32
        'SERVER_ADMIN',
33
        'SERVER_PORT',
34
        'SERVER_SIGNATURE',
35
        'PATH_TRANSLATED',
36
        'SCRIPT_NAME',
37
        'REQUEST_URI',
38
        'PHP_AUTH_DIGEST',
39
        'PHP_AUTH_USER',
40
        'PHP_AUTH_PW',
41
        'AUTH_TYPE',
42
        'PATH_INFO',
43
        'ORIG_PATH_INFO',
44
        'APP_ENV',
45
    ];
46
47
    /**
48
     * @var array
49
     */
50
    protected $includeKeys = [];
51
52
    /**
53
     * @var array
54
     */
55
    protected $server = [];
56
57
    /**
58
     * @param  array  $server
59
     * @param  array  $env
60
     */
61
    public function __construct(array $server = null, array $env = null)
62
    {
63
        $this->server = array_merge(
64
            $server ?? $_SERVER,
65
            $env ?? $_ENV
66
        );
67
68
        $this->keysToFilter = ['HTTP_AUTHORIZATION'];
69
    }
70
71
    /**
72
     * @return array
73
     */
74
    public function values(): array
75
    {
76
        return $this->filter($this->data());
77
    }
78
79
    /**
80
     * @param  array  $keysToInclude
81
     * @return \Honeybadger\Environment
82
     */
83
    public function include(array $keysToInclude): self
84
    {
85
        $this->includeKeys = array_merge($this->includeKeys, $keysToInclude);
86
87
        return $this;
88
    }
89
90
    /**
91
     * @return array
92
     */
93
    private function data(): array
94
    {
95
        return array_filter($this->server, function ($key) {
96
            return $this->autoIncludeKey($key) || in_array($key, $this->includeKeys);
97
        }, ARRAY_FILTER_USE_KEY);
98
    }
99
100
    /**
101
     * @param  string  $key
102
     * @return bool
103
     */
104
    private function whitelistKey(string $key): bool
105
    {
106
        return in_array($key, self::KEY_WHITELIST);
107
    }
108
109
    /**
110
     * @param  string  $key
111
     * @return bool
112
     */
113
    private function httpKey(string $key): bool
114
    {
115
        return strpos($key, 'HTTP_') === 0;
116
    }
117
118
    /**
119
     * @param  string  $key
120
     * @return bool
121
     */
122
    private function autoIncludeKey(string $key): bool
123
    {
124
        return $this->whitelistKey($key) || $this->httpKey($key);
125
    }
126
}
127