Passed
Push — dev ( 12a43b...73b6af )
by Nico
35:42 queued 18:23
created

ModuleViewEnum::getTemplate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 1.0001

Importance

Changes 0
Metric Value
cc 1
eloc 20
nc 1
nop 0
dl 0
loc 22
ccs 20
cts 21
cp 0.9524
crap 1.0001
rs 9.6
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Component\Game;
6
7
use RuntimeException;
8
use Stu\Lib\Component\ComponentEnumInterface;
9
use Stu\Module\Colony\Component\ColonyComponentEnum;
10
use Stu\Module\Game\Component\GameComponentEnum;
11
12
//TODO rename to ModuleEnum
13
enum ModuleViewEnum: string
14
{
15
    case INDEX = 'index';
16
    case GAME = 'game';
17
    case MAINDESK = 'maindesk';
18
    case COLONY = 'colony';
19
    case SHIP = 'ship';
20
    case STATION = 'station';
21
    case COMMUNICATION = 'comm';
22
    case PM = 'pm';
23
    case NOTES = 'notes';
24
    case RESEARCH = 'research';
25
    case TRADE = 'trade';
26
    case ALLIANCE = 'alliance';
27
    case DATABASE = 'database';
28
    case HISTORY = 'history';
29
    case MAP = 'starmap';
30
    case OPTIONS = 'options';
31
    case USERPROFILE = 'userprofile';
32
    case ADMIN = 'admin';
33
    case NPC = 'npc';
34
35 40
    public function getPhpPage(): string
36
    {
37 40
        return sprintf('%s.php', $this->value);
38
    }
39
40 20
    public function getTitle(): string
41
    {
42 20
        return match ($this) {
43 20
            self::INDEX => 'Star Trek Universe - Login',
44 19
            self::GAME => 'Star Trek Universe',
45 19
            self::MAINDESK => 'Maindesk',
46 17
            self::COLONY => 'Kolonien',
47 16
            self::SHIP => 'Schiffe',
48 15
            self::STATION => 'Stationen',
49 14
            self::COMMUNICATION => 'KommNet',
50 13
            self::PM => 'Nachrichten',
51 11
            self::RESEARCH => 'Forschung',
52 10
            self::TRADE => 'Handel',
53 9
            self::ALLIANCE => 'Allianz',
54 8
            self::DATABASE => 'Datenbank',
55 7
            self::HISTORY => 'Ereignisse',
56 6
            self::MAP => 'Karte',
57 2
            self::NOTES => 'Notizen',
58 2
            self::OPTIONS => 'Optionen',
59 2
            self::USERPROFILE => 'Spielerprofil',
60
            self::ADMIN => 'Adminbereich',
61 20
            self::NPC => 'NPC'
62 20
        };
63
    }
64
65 23
    public function getTemplate(): string
66
    {
67 23
        return match ($this) {
68 23
            self::INDEX => 'html/index/index.twig',
69 22
            self::GAME => 'html/game/game.twig',
70 19
            self::MAINDESK => 'html/view/maindesk.twig',
71 18
            self::COLONY => 'html/view/colonylist.twig',
72 17
            self::SHIP => 'html/view/shiplist.twig',
73 16
            self::STATION => 'html/view/stationList.twig',
74 15
            self::COMMUNICATION => 'html/view/communication.twig',
75 10
            self::PM => 'html/view/pmCategory.twig',
76 8
            self::RESEARCH => 'html/view/research.twig',
77 7
            self::TRADE => 'html/view/trade.twig',
78 6
            self::ALLIANCE => 'html/view/alliance.twig',
79 5
            self::DATABASE => 'html/view/database.twig',
80 4
            self::HISTORY => 'html/view/history.twig',
81 3
            self::MAP => 'html/view/map.twig',
82 2
            self::NOTES => 'not needed',
83 2
            self::OPTIONS => 'html/view/options.twig',
84 1
            self::USERPROFILE => 'html/view/userprofile.twig',
85
            self::ADMIN => 'not needed',
86 23
            self::NPC => 'not needed'
87 23
        };
88
    }
89
90 6
    public function getComponentEnum(string $value): ComponentEnumInterface
91
    {
92 6
        $result =  match ($this) {
93 6
            self::GAME => GameComponentEnum::tryFrom($value),
94 2
            self::COLONY => ColonyComponentEnum::tryFrom($value),
95 1
            default => throw new RuntimeException('no components in this module view')
96 6
        };
97
98 5
        return $result ?? GameComponentEnum::OUTDATED;
99
    }
100
101
    public function getCommonModule(): ?string
102
    {
103
        return match ($this) {
104
            self::SHIP,
105
            self::STATION => 'SPACECRAFT',
106
            default => null
107
        };
108
    }
109
}
110