EloquentSnapshot   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toSnapshot() 0 4 1
A scopeUuid() 0 4 1
1
<?php
2
3
namespace Spatie\EventSourcing\Snapshots;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model;
7
8
class EloquentSnapshot extends Model
9
{
10
    public $guarded = [];
11
12
    protected $table = 'snapshots';
13
14
    public $casts = [
15
        'state' => 'array',
16
    ];
17
18
    public function toSnapshot(): Snapshot
19
    {
20
        return new Snapshot($this->aggregate_uuid, $this->aggregate_version, $this->state);
21
    }
22
23
    public function scopeUuid(Builder $query, string $uuid): void
24
    {
25
        $query->where('aggregate_uuid', $uuid);
26
    }
27
}
28