Completed
Push — master ( 00f04e...1d93d6 )
by Freek
03:46
created

HandleStoredEventJob   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 5
dl 0
loc 34
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\EventSourcing;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Illuminate\Queue\InteractsWithQueue;
8
use Illuminate\Queue\SerializesModels;
9
10
final class HandleStoredEventJob implements HandleDomainEventJob, ShouldQueue
11
{
12
    use InteractsWithQueue, Queueable, SerializesModels;
13
14
    public StoredEvent $storedEvent;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
15
16
    public array $tags;
17
18
    public function __construct(StoredEvent $storedEvent, array $tags)
19
    {
20
        $this->storedEvent = $storedEvent;
21
22
        $this->tags = $tags;
23
    }
24
25
    public function handle(Projectionist $projectionist): void
26
    {
27
        $projectionist->handle($this->storedEvent);
28
    }
29
30
    public function tags(): array
31
    {
32
        return empty($this->tags)
33
            ? [$this->storedEvent->event_class]
34
            : $this->tags;
35
    }
36
37
    public static function createForEvent(StoredEvent $event, array $tags): HandleDomainEventJob
38
    {
39
        return new static($event, $tags);
40
    }
41
}
42