Completed
Push — master ( a0d1c0...57787d )
by Freek
01:36
created

ProjectsEvents::hasReceivedAllEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Spatie\EventProjector\Projectors;
4
5
use Spatie\EventProjector\Models\ProjectorStatus;
6
use Spatie\EventProjector\Models\StoredEvent;
7
8
trait ProjectsEvents
9
{
10
    public function hasReceivedAllPriorEvents(StoredEvent $storedEvent): bool
11
    {
12
        return $storedEvent->id === $this->getStatus()->last_processed_event_id + 1;
13
    }
14
15
    public function rememberReceivedEvent(StoredEvent $storedEvent)
16
    {
17
        $this->getStatus()->rememberLastProcessedEvent($storedEvent);
18
    }
19
20
    public function hasReceivedAllEvents(): bool
21
    {
22
        return $this->getStatus()->last_processed_event_id === StoredEvent::getMaxId();
23
    }
24
25
    public function getName(): string
26
    {
27
        return get_class($this);
28
    }
29
30
    protected function getStatus(): ProjectorStatus
31
    {
32
        return ProjectorStatus::getForProjector($this);
33
    }
34
35
36
}