Passed
Push — master ( 30d3d2...4e3abd )
by Jesse
01:56
created

AccountOverviewCreator::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\CardGame\EventHandler;
4
5
use function assert;
6
use Stratadox\CardGame\DomainEvent;
7
use Stratadox\CardGame\Account\VisitorOpenedAnAccount;
8
use Stratadox\CardGame\ReadModel\Account\AccountOverview;
9
use Stratadox\CardGame\ReadModel\Account\AccountOverviews;
10
11
final class AccountOverviewCreator implements EventHandler
12
{
13
    private $accountOverviews;
14
15
    public function __construct(AccountOverviews $accountOverviews)
16
    {
17
        $this->accountOverviews = $accountOverviews;
18
    }
19
20
    public function events(): iterable
21
    {
22
        return [VisitorOpenedAnAccount::class];
23
    }
24
25
    public function handle(DomainEvent $event): void
26
    {
27
        assert($event instanceof VisitorOpenedAnAccount);
28
29
        $this->accountOverviews->add(new AccountOverview(
30
            $event->aggregateId(),
31
            $event->forVisitor()
32
        ));
33
    }
34
}
35