Passed
Pull Request — dev (#2038)
by Janko
10:55
created

CrewPositionEnum::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 10
ccs 9
cts 9
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Component\Crew;
6
7
enum CrewPositionEnum: int
8
{
9
    case COMMAND = 1;
10
    case SECURITY = 2;
11
    case SCIENCE = 3;
12
    case TECHNICAL = 4;
13
    case NAVIGATION = 5;
14
    case CREWMAN = 6;
15
    case CAPTAIN = 7;
16
17 2
    public function getDescription(): string
18
    {
19 2
        return match ($this) {
20 2
            self::CAPTAIN => "Captain",
21 2
            self::COMMAND => "Commander",
22 1
            self::SECURITY => "Sicherheit",
23 1
            self::SCIENCE => "Wissenschaftler",
24 1
            self::TECHNICAL => "Ingenieur",
25 1
            self::NAVIGATION => "Navigator",
26 2
            self::CREWMAN => "Crewman",
27 2
        };
28
    }
29
30 2
    public function getFightCapability(): int
31
    {
32 2
        return match ($this) {
33 2
            self::SECURITY => 20,
34 2
            self::CAPTAIN => 10,
35 2
            self::COMMAND => 8,
36 2
            self::CREWMAN => 6,
37 2
            self::TECHNICAL => 4,
38 2
            self::NAVIGATION => 2,
39 2
            self::SCIENCE => 0
40 2
        };
41
    }
42
43
    /** @return array<CrewPositionEnum> */
44
    public static function getOrder(): array
45
    {
46
        return [
47
            self::CAPTAIN,
48
            self::COMMAND,
49
            self::SECURITY,
50
            self::SCIENCE,
51
            self::TECHNICAL,
52
            self::NAVIGATION,
53
            self::CREWMAN
54
        ];
55
    }
56
}
57