InMemoryMatches::withId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\CardGame\Infrastructure\Test;
4
5
use function array_values;
6
use Stratadox\CardGame\Match\Match;
7
use Stratadox\CardGame\Match\Matches;
8
use Stratadox\CardGame\Match\MatchId;
9
10
final class InMemoryMatches implements Matches
11
{
12
    /** @var Match[] */
13
    private $matches = [];
14
15
    public function add(Match $match): void
16
    {
17
        $this->matches[(string) $match->id()] = $match;
18
    }
19
20
    public function withId(MatchId $match): Match
21
    {
22
        // @todo throw if no such match
23
        return $this->matches[$match->id()];
24
    }
25
26
    public function ongoing(): array
27
    {
28
        // @todo filter this once matches can end
29
        return array_values($this->matches);
30
    }
31
}
32