Skip to content

API reference / Quittio \ Core \ Support

DatedValues

final readonly class in quittio/core

Quittio\Core\Support\DatedValues · Source

Values that change on dates, e.g. tax rates or reference interest rates: every value holds from its date until the next change.

Methods#

MethodDescription
->__construct()
->changes()Every change: ISO date => value, sorted by date.
->lastChange()Date of the last change; null without values.
->on()The value that holds on the date; null before the first change.
->periods()The periods of constant value between two dates (both included), in order; days before the first change are left out.
->withValue()A copy with a value that holds from $from on; an existing value of that date is replaced.

__construct()#

public function __construct(array<string, string> $values)
ParameterTypeDescription
$valuesarray<string, string>ISO date (YYYY-MM-DD) => value from that date on
Throws
InvalidArgumentException – for a key that is no ISO date

changes()#

public function changes(): array<string, string>

Every change: ISO date => value, sorted by date.

Returns
array<string, string>

lastChange()#

public function lastChange(): ?Date

Date of the last change; null without values.

Returns
?Date

on()#

public function on(Date $date): ?string

The value that holds on the date; null before the first change.

ParameterTypeDescription
$dateDate
Returns
?string

periods()#

public function periods(
    Date $from,
    Date $until,
): list<array{from: Date, until: Date, value: string}>

The periods of constant value between two dates (both included), in order; days before the first change are left out.

ParameterTypeDescription
$fromDate
$untilDate
Returns
list<array{from: Date, until: Date, value: string}>

withValue()#

public function withValue(Date|string $from, string $value): self

A copy with a value that holds from $from on; an existing value of that date is replaced.

ParameterTypeDescription
$fromDate|string
$valuestring
Returns
self

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