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

ProjectorStatus   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getForProjector() 0 4 1
A rememberLastProcessedEvent() 0 8 1
1
<?php
2
3
namespace Spatie\EventProjector\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Spatie\EventProjector\Projectors\Projector;
7
8
class ProjectorStatus extends Model
9
{
10
    public $guarded = [];
11
12
    public static function getForProjector(Projector $projector): ProjectorStatus
13
    {
14
        return ProjectorStatus::firstOrCreate(['projector_name' => $projector->getName()]);
15
    }
16
17
    public function rememberLastProcessedEvent(StoredEvent $storedEvent): self
18
    {
19
        $this->last_processed_event_id = $storedEvent->id;
20
21
        $this->save();
22
23
        return $this;
24
    }
25
}
26