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.

Config   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 1
dl 0
loc 103
ccs 25
cts 25
cp 1
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A has() 0 8 2
A get() 0 8 2
A getRequired() 0 8 2
A all() 0 4 1
A offsetExists() 0 4 1
A offsetGet() 0 4 1
A offsetSet() 0 4 1
A offsetUnset() 0 4 1
1
<?php declare(strict_types=1);
2
/**
3
 * Starlit App.
4
 *
5
 * @copyright Copyright (c) 2016 Starweb AB
6
 * @license   BSD 3-Clause
7
 */
8
9
namespace Starlit\App;
10
11
use Starlit\Utils\Arr;
12
13
class Config implements \ArrayAccess
14
{
15
    /**
16
     * @var array
17
     */
18
    protected $data;
19
20 33
    public function __construct(array $data = [])
21
    {
22 33
        $this->data = $data;
23 33
    }
24
25 30
    public function has(string $key): bool
26
    {
27 30
        if (empty($this->data[$key])) {
28 25
            return false;
29
        }
30
31 28
        return !Arr::allEmpty($this->data[$key]);
32
    }
33
34
    /**
35
     * Get the specified configuration value.
36
     *
37
     * @param string $key
38
     * @param mixed  $default
39
     * @return mixed
40
     */
41 26
    public function get(string $key, $default = null)
42
    {
43 26
        if ($this->has($key)) {
44 25
            return $this->data[$key];
45
        }
46
47 3
        return $default;
48
    }
49
50
    /**
51
     * Get the specified required configuration value.
52
     * Will throw an exception if not set.
53
     *
54
     * @param string $key
55
     * @return mixed
56
     */
57 2
    public function getRequired(string $key)
58
    {
59 2
        if (!$this->has($key)) {
60 1
            throw new \RuntimeException("Config key \"{$key}\" not found");
61
        }
62
63 1
        return $this->get($key);
64
    }
65
66 1
    public function all(): array
67
    {
68 1
        return $this->data;
69
    }
70
71
    /**
72
     * Determine if the given configuration option exists.
73
     *
74
     * @param string $key
75
     * @return bool
76
     */
77 1
    public function offsetExists($key): bool
78
    {
79 1
        return $this->has($key);
80
    }
81
82
    /**
83
     * Get a configuration option.
84
     *
85
     * @param string $key
86
     * @return mixed
87
     */
88 1
    public function offsetGet($key)
89
    {
90 1
        return $this->get($key);
91
    }
92
93
    /**
94
     * Set a configuration option.
95
     *
96
     * @param string $key
97
     * @param mixed  $value
98
     * @throws \LogicException
99
     */
100 1
    public function offsetSet($key, $value): void
101
    {
102 1
        throw new \LogicException('Config is immutable');
103
    }
104
105
    /**
106
     * Unset a configuration option.
107
     *
108
     * @param string $key
109
     * @throws \LogicException
110
     */
111 1
    public function offsetUnset($key): void
112
    {
113 1
        throw new \LogicException('Config is immutable');
114
    }
115
}
116