Passed
Pull Request — master (#1819)
by Nico
52:14 queued 25:19
created

ShipAttackCauseEnum   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 24
dl 0
loc 33
ccs 19
cts 19
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDestructionCause() 0 10 1
A isOneWay() 0 10 1
1
<?php
2
3
namespace Stu\Module\Ship\Lib\Battle;
4
5
use Stu\Module\Ship\Lib\Destruction\ShipDestructionCauseEnum;
6
7
enum ShipAttackCauseEnum
8
{
9
    case SHIP_FIGHT;
10
    case ALERT_YELLOW;
11
    case ALERT_RED;
12
    case COLONY_DEFENSE;
13
    case ACTIVATE_TRACTOR;
14
    case BOARD_SHIP;
15
    case THOLIAN_WEB_REFLECTION;
16
17 1
    public function isOneWay(): bool
18
    {
19 1
        return match ($this) {
20 1
            self::SHIP_FIGHT => false,
21 1
            self::ALERT_YELLOW => false,
22 1
            self::ALERT_RED => false,
23 1
            self::COLONY_DEFENSE => false,
24 1
            self::ACTIVATE_TRACTOR => true,
25 1
            self::BOARD_SHIP => true,
26 1
            self::THOLIAN_WEB_REFLECTION => true,
27 1
        };
28
    }
29
30 1
    public function getDestructionCause(): ShipDestructionCauseEnum
31
    {
32 1
        return match ($this) {
33 1
            self::SHIP_FIGHT => ShipDestructionCauseEnum::SHIP_FIGHT,
34 1
            self::ALERT_YELLOW => ShipDestructionCauseEnum::ALERT_YELLOW,
35 1
            self::ALERT_RED => ShipDestructionCauseEnum::ALERT_RED,
36 1
            self::COLONY_DEFENSE => ShipDestructionCauseEnum::SHIP_FIGHT,
37 1
            self::ACTIVATE_TRACTOR => ShipDestructionCauseEnum::SHIP_FIGHT,
38 1
            self::BOARD_SHIP => ShipDestructionCauseEnum::SHIP_FIGHT,
39 1
            self::THOLIAN_WEB_REFLECTION => ShipDestructionCauseEnum::SHIP_FIGHT
40 1
        };
41
    }
42
}
43