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::getDatabase()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Webparking\DbRebuild;
4
5
class Config
6
{
7
    /** @var string */
8
    private $preset;
9
10 14
    public function __construct($preset)
11
    {
12 14
        if (!\is_string($preset)) {
13 1
            throw new \RuntimeException('Preset names must be strings');
14
        }
15
16 13
        if (config('db-rebuild.presets.' . $preset) === null) {
17 1
            throw new \RuntimeException("Preset '{$preset}' doesn't exist");
18
        }
19
20 12
        $this->preset = $preset;
21 12
    }
22
23 12
    private function getConfig(string $key, $default)
24
    {
25 12
        return config('db-rebuild.presets.' . $this->preset . '.' . $key, $default);
26
    }
27
28 9
    private function getArrayConfig(string $key, array $default = []): array
29
    {
30 9
        $data = $this->getConfig($key, $default);
31
32 9
        if (\is_array($data)) {
33 8
            return $data;
34
        }
35
36 3
        throw new \RuntimeException("db-rebuild.presets.{$this->preset}.{$key} should be an array");
37
    }
38
39 12
    private function getStringConfig(string $key, string $default): string
40
    {
41 12
        $data = $this->getConfig($key, $default);
42
43 12
        if (\is_string($data)) {
44 11
            return $data;
45
        }
46
47 1
        throw new \RuntimeException("db-rebuild.presets.{$this->preset}.{$key} should be a string");
48
    }
49
50 12
    public function getDatabase(): string
51
    {
52 12
        return $this->getStringConfig('database', config('database.connections.' . config('database.default') . '.database'));
53
    }
54
55 8
    public function getCommands(): array
56
    {
57 8
        return $this->getArrayConfig('commands');
58
    }
59
60 9
    public function getBackup(): array
61
    {
62 9
        return $this->getArrayConfig('backup');
63
    }
64
65 7
    public function getSeeds(): array
66
    {
67 7
        return $this->getArrayConfig('seeds');
68
    }
69
}
70