Issues (11)

src/EventHandler/ProposalSender.php (1 issue)

Labels
Severity
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\Proposal\MatchWasProposed;
8
use Stratadox\CardGame\ReadModel\Linker;
0 ignored issues
show
The type Stratadox\CardGame\ReadModel\Linker was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Stratadox\CardGame\ReadModel\Proposal\MatchProposal;
10
use Stratadox\CardGame\ReadModel\Proposal\MatchProposals;
11
12
final class ProposalSender implements EventHandler
13
{
14
    private $proposals;
15
16
    public function __construct(MatchProposals $proposals)
17
    {
18
        $this->proposals = $proposals;
19
    }
20
21
    public function events(): iterable
22
    {
23
        return [MatchWasProposed::class];
24
    }
25
26
    public function handle(DomainEvent $event): void
27
    {
28
        assert($event instanceof MatchWasProposed);
29
30
        $this->proposals->add(
31
            new MatchProposal(
32
                $event->aggregateId(),
33
                $event->proposedBy(),
34
                $event->proposedTo(),
35
                $event->validUntil()
36
            )
37
        );
38
    }
39
}
40