TurnPhaseExpirationProcess::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\CardGame\Match\Handler;
4
5
use Stratadox\CardGame\Command;
6
use Stratadox\CardGame\CommandHandler;
7
use Stratadox\CardGame\EventBag;
8
use Stratadox\CardGame\Match\Matches;
9
use Stratadox\Clock\Clock;
10
11
final class TurnPhaseExpirationProcess implements CommandHandler
12
{
13
    /** @var Matches */
14
    private $matches;
15
    /** @var Clock */
16
    private $clock;
17
    /** @var EventBag */
18
    private $eventBag;
19
20
    public function __construct(
21
        Matches $matches,
22
        Clock $clock,
23
        EventBag $eventBag
24
    ) {
25
        $this->matches = $matches;
26
        $this->clock = $clock;
27
        $this->eventBag = $eventBag;
28
    }
29
30
    public function handle(Command $command): void
31
    {
32
        foreach ($this->matches->ongoing() as $ongoingMatch) {
33
            $ongoingMatch->endExpiredTurnOrPhase($this->clock->now());
34
            $this->eventBag->takeFrom($ongoingMatch);
35
        }
36
    }
37
}
38