Skip to content

API reference / Quittio \ Core \ Validation

ValidationContext

final readonly class in quittio/core

Quittio\Core\Validation\ValidationContext · Source

Information available to rules while validating an invoice.

Properties#

PropertyTypeDescription
$countryPacks readonlylist<CountryPack>leading pack first
$locale readonlystring
$messageLocale readonly?string
$options readonlyarray<string, mixed>e.g. attachment_max_bytes, attachments_max_total_bytes
$profile readonlyProfile
$translator readonly?Translator

Methods#

MethodDescription
->__construct()
->hasCountry()Whether a country pack with $code, e.g. "DE", takes part in the run, leading or for the buyer's country.
->intOption()The option $key as an integer, e.g. "attachment_max_bytes"; $default when it is not set or not an integer.
->leadingCountry()Code of the leading country pack (the seller's country), e.g. "DE"; null without country packs.
->messageLocale()Language of the messages: the configured one (validation.locale), otherwise the language of the run. Rules that check texts of the invoice use $locale instead.
->option()The option $key of the run, e.g. "syntax" while the XML of a syntax is checked; $default when it is not set or null.
->profileIs()Whether the profile's key is one of $keys, e.g. "xrechnung" or "xrechnung-extension".
->translator()Translator for the messages: the one given to this context, otherwise the shared one of Translations::translator().

__construct()#

public function __construct(
    Profile $profile,
    list<CountryPack> $countryPacks = [],
    string $locale = 'en',
    ?Translator $translator = null,
    array<string, mixed> $options = [],
    ?string $messageLocale = null,
)
ParameterTypeDescription
$profileProfile
$countryPackslist<CountryPack> = []leading pack first
$localestring = 'en'
$translator?Translator = null
$optionsarray<string, mixed> = []e.g. attachment_max_bytes, attachments_max_total_bytes
$messageLocale?string = null

hasCountry()#

public function hasCountry(string $code): bool

Whether a country pack with $code, e.g. "DE", takes part in the run, leading or for the buyer's country.

ParameterTypeDescription
$codestring
Returns
bool

intOption()#

public function intOption(string $key, int $default): int

The option $key as an integer, e.g. "attachment_max_bytes"; $default when it is not set or not an integer.

ParameterTypeDescription
$keystring
$defaultint
Returns
int

leadingCountry()#

public function leadingCountry(): ?string

Code of the leading country pack (the seller's country), e.g. "DE"; null without country packs.

Returns
?string

messageLocale()#

public function messageLocale(): string

Language of the messages: the configured one (validation.locale), otherwise the language of the run. Rules that check texts of the invoice use $locale instead.

Returns
string

option()#

public function option(string $key, mixed $default = null): mixed

The option $key of the run, e.g. "syntax" while the XML of a syntax is checked; $default when it is not set or null.

ParameterTypeDescription
$keystring
$defaultmixed = null
Returns
mixed

profileIs()#

public function profileIs(string ...$keys): bool

Whether the profile's key is one of $keys, e.g. "xrechnung" or "xrechnung-extension".

ParameterTypeDescription
...$keysstring
Returns
bool

translator()#

public function translator(): Translator

Translator for the messages: the one given to this context, otherwise the shared one of Translations::translator().

Returns
Translator

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