Passed
Pull Request — master (#1914)
by Janko
81:21
created

StuConfigSettingEnum::getParent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 0
dl 0
loc 13
ccs 0
cts 12
cp 0
crap 2
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace Stu\Module\Config;
4
5
enum StuConfigSettingEnum: int
6
{
7
    case ADMIN = 1;
8
    case CACHE = 2;
9
    case COLONY = 3;
10
    case DB = 4;
11
    case DEBUG = 5;
12
    case GAME = 6;
13
    case MAP = 7;
14
    case RESET = 8;
15
    case SQL_LOGGING = 9;
16
    case EMAIL = 10;
17
18
    public function getParent(): ?StuConfigSettingEnum
19
    {
20
        return match ($this) {
21
            self::ADMIN => self::GAME,
22
            self::CACHE => null,
23
            self::COLONY => self::GAME,
24
            self::DB => null,
25
            self::DEBUG => null,
26
            self::GAME => null,
27
            self::MAP => self::GAME,
28
            self::RESET => null,
29
            self::SQL_LOGGING => self::DEBUG,
30
            self::EMAIL => self::GAME
31
        };
32
    }
33
34 4
    public function getConfigPath(): string
35
    {
36 4
        return match ($this) {
37 4
            self::ADMIN => 'admin',
38 4
            self::CACHE => 'cache',
39 4
            self::COLONY => 'colony',
40 4
            self::DB => 'db',
41 4
            self::DEBUG => 'debug',
42 4
            self::GAME => 'game',
43 4
            self::MAP => 'map',
44 4
            self::RESET => 'reset',
45 4
            self::SQL_LOGGING => 'sqlLogging',
46 4
            self::EMAIL => 'email'
47 4
        };
48
    }
49
}
50