Test Setup Failed
Push — master ( 647a95...23a558 )
by Jesse
02:13
created

TurnPhase::endCardPlaying()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\CardGame\Match;
4
5
final class TurnPhase
6
{
7
    private const DEFEND = 0;
8
    private const PLAY = 1;
9
    private const ATTACK = 2;
10
11
    private $phase;
12
13
    private function __construct(int $phase)
14
    {
15
        $this->phase = $phase;
16
    }
17
18
    public static function defend(): self
19
    {
20
        return new self(TurnPhase::DEFEND);
21
    }
22
23
    public static function play(): self
24
    {
25
        return new self(TurnPhase::PLAY);
26
    }
27
28
    public static function attack(): self
29
    {
30
        return new self(TurnPhase::ATTACK);
31
    }
32
33
    public function prohibitsDefending(): bool
34
    {
35
        return $this->phase !== TurnPhase::DEFEND;
36
    }
37
38
    public function prohibitsPlaying(): bool
39
    {
40
        return $this->phase !== TurnPhase::PLAY;
41
    }
42
43
    public function prohibitsAttacking(): bool
44
    {
45
        return $this->phase !== TurnPhase::ATTACK;
46
    }
47
48
    public function isAfterCombat(): bool
49
    {
50
        return $this->phase === TurnPhase::PLAY
51
            || $this->phase === TurnPhase::ATTACK;
52
    }
53
54
    public function endCombat(): TurnPhase
55
    {
56
        return TurnPhase::play();
57
    }
58
59
    public function endCardPlaying(): TurnPhase
60
    {
61
        return TurnPhase::attack();
62
    }
63
}
64