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 63
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 63
ccs 27
cts 27
cp 1
rs 10
wmc 12

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 3
A getSeeds() 0 3 1
A getStringConfig() 0 9 2
A getCommands() 0 3 1
A getConfig() 0 3 1
A getDatabase() 0 3 1
A getBackup() 0 3 1
A getArrayConfig() 0 9 2
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