Skip to content

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#

MethodDescription
->__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 = [])
ParameterTypeDescription
$upcastersiterable<SnapshotUpcaster> = []

default()#

public static function default(): self

static

Shared instance used by InvoiceData::fromSnapshot().

Returns
self

documentDefault()#

public static function documentDefault(): self

static

Shared instance used by DocumentData::fromSnapshot(). Documents have their own versions.

Returns
self

register()#

public function register(SnapshotUpcaster $upcaster): self
ParameterTypeDescription
$upcasterSnapshotUpcaster
Returns
self

upcast()#

public function upcast(
    array<string, mixed> $snapshot,
    int $from,
    int $to = \Quittio\Core\Data\InvoiceData::SNAPSHOT_VERSION,
): array<string, mixed>
ParameterTypeDescription
$snapshotarray<string, mixed>without the "_version" key
$fromint
$toint = \Quittio\Core\Data\InvoiceData::SNAPSHOT_VERSION
Returns
array<string, mixed>

useDefault()#

public static function useDefault(?self $chain): void

static

Replaces the shared instance of InvoiceData::fromSnapshot(); null resets it.

ParameterTypeDescription
$chain?self

useDocumentDefault()#

public static function useDocumentDefault(?self $chain): void

static

Replaces the shared instance of DocumentData::fromSnapshot(); null resets it.

ParameterTypeDescription
$chain?self

The open core packages are MIT licensed. The legal wording of the country packs must be confirmed by a tax adviser.