EloquentSnapshot::toSnapshot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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