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

ShipAttackCauseEnum::getDestructionCause()   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 1
Bugs 0 Features 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 1
b 0
f 0
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