Test Setup Failed
Push — master ( a63fa0...36623d )
by Jesse
04:59
created

Battlefields::cardsInPlay()   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
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\CardGame\ReadModel\Match;
4
5
use function array_key_exists;
6
use Stratadox\CardGame\Match\MatchId;
7
8
class Battlefields
9
{
10
    private $battlefields = [];
11
12
    public function for(MatchId $match): Battlefield
13
    {
14
        if (!array_key_exists($match->id(), $this->battlefields)) {
15
            $this->battlefields[$match->id()] = Battlefield::untouched();
16
        }
17
        return $this->battlefields[$match->id()];
18
    }
19
20
    /** @return Card[] */
21
    public function cardsInPlay(MatchId $match): array
22
    {
23
        return $this->for($match)->cardsInPlay();
24
    }
25
26
    /** @return Card[] */
27
    public function cardsInPlayFor(int $player, MatchId $match): array
28
    {
29
        return $this->for($match)->cardsInPlayFor($player);
30
    }
31
32
    /** @return Card[] */
33
    public function attackers(MatchId $match): array
34
    {
35
        return $this->for($match)->attackers();
36
    }
37
38
    /** @return Card[] */
39
    public function defenders(MatchId $match): array
40
    {
41
        return $this->for($match)->defenders();
42
    }
43
}
44