API reference / Quittio \ Core \ Serialization \ Snapshots
SnapshotUpcasterChain
final class in quittio/core
Quittio\Core\Serialization\Snapshots\SnapshotUpcasterChain · Source
Brings stored snapshots step by step to the current version (v1 → v2 → … → current).
Methods#
| Method | Description |
|---|---|
->__construct() | |
::default() | Shared instance used by InvoiceData::fromSnapshot(). |
::documentDefault() | Shared instance used by DocumentData::fromSnapshot(). Documents have their own versions. |
->register() | |
->upcast() | |
::useDefault() | Replaces the shared instance of InvoiceData::fromSnapshot(); null resets it. |
::useDocumentDefault() | Replaces the shared instance of DocumentData::fromSnapshot(); null resets it. |
__construct()#
public function __construct(iterable<SnapshotUpcaster> $upcasters = [])| Parameter | Type | Description |
|---|---|---|
$upcasters | iterable<SnapshotUpcaster> = [] |
default()#
public static function default(): selfShared instance used by InvoiceData::fromSnapshot().
- Returns
self
documentDefault()#
public static function documentDefault(): selfShared instance used by DocumentData::fromSnapshot(). Documents have their own versions.
- Returns
self
register()#
public function register(SnapshotUpcaster $upcaster): self| Parameter | Type | Description |
|---|---|---|
$upcaster | SnapshotUpcaster |
- Returns
self
upcast()#
public function upcast(
array<string, mixed> $snapshot,
int $from,
int $to = \Quittio\Core\Data\InvoiceData::SNAPSHOT_VERSION,
): array<string, mixed>| Parameter | Type | Description |
|---|---|---|
$snapshot | array<string, mixed> | without the "_version" key |
$from | int | |
$to | int = \Quittio\Core\Data\InvoiceData::SNAPSHOT_VERSION |
- Returns
array<string, mixed>
useDefault()#
public static function useDefault(?self $chain): voidReplaces the shared instance of InvoiceData::fromSnapshot(); null resets it.
| Parameter | Type | Description |
|---|---|---|
$chain | ?self |
useDocumentDefault()#
public static function useDocumentDefault(?self $chain): voidReplaces the shared instance of DocumentData::fromSnapshot(); null resets it.
| Parameter | Type | Description |
|---|---|---|
$chain | ?self |