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
03:11
created

Config   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 56
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A mergeConfig() 0 30 1
A __construct() 0 4 1
A validateRequiredKeys() 0 4 3
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