InMemoryMatches   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A ongoing() 0 4 1
A add() 0 3 1
A withId() 0 4 1
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