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.
Completed
Pull Request — master (#57)
by TJ
02:43
created

Config::mergeConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 23
nc 1
nop 1
dl 0
loc 30
rs 9.552
c 0
b 0
f 0
1
<?php
2
3
namespace Honeybadger;
4
5
use InvalidArgumentException;
6
use Honeybadger\Support\Repository;
7
8
class Config extends Repository
9
{
10
    /**
11
     * @param  array  $config
12
     */
13
    public function __construct($config = [])
14
    {
15
        $this->items = $this->mergeConfig($config);
16
        $this->validateRequiredKeys();
17
    }
18
19
    /**
20
     * @param  array  $config
21
     * @return array
22
     */
23
    private function mergeConfig($config = []) : array
24
    {
25
        return array_merge([
26
            'api_key' => null,
27
            'notifier' => [
28
                'name' => 'Honeybadger PHP',
29
                'url' => 'https://github.com/honeybadger-io/honeybadger-php',
30
                'version' => Honeybadger::VERSION,
31
            ],
32
            'environment' => [
33
                'filter' => [],
34
                'include' => [],
35
            ],
36
            'request' => [
37
                'filter' => [],
38
            ],
39
            'version' => '',
40
            'hostname' => gethostname(),
41
            'project_root' => '',
42
            'environment_name' => 'production',
43
            'handlers' => [
44
                'exception' => true,
45
                'error' => true,
46
            ],
47
            'client' => [
48
                'timeout' => 0,
49
                'proxy' => [],
50
            ],
51
            'excluded_exceptions' => [],
52
        ], $config);
53
    }
54
55
    /**
56
     * @return void
57
     *
58
     * @throws \InvalidArgument\Exception
59
     */
60
    private function validateRequiredKeys() : void
61
    {
62
        if (! isset($this->items['api_key']) || is_null($this->items['api_key'])) {
63
            throw new InvalidArgumentException('$config[\'api_key\'] is required');
64
        }
65
    }
66
}
67