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#
| Property | Type | Description |
|---|---|---|
$countryPacks readonly | list<CountryPack> | leading pack first |
$locale readonly | string | |
$messageLocale readonly | ?string | |
$options readonly | array<string, mixed> | e.g. attachment_max_bytes, attachments_max_total_bytes |
$profile readonly | Profile | |
$translator readonly | ?Translator |
Methods#
| Method | Description |
|---|---|
->__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,
)| Parameter | Type | Description |
|---|---|---|
$profile | Profile | |
$countryPacks | list<CountryPack> = [] | leading pack first |
$locale | string = 'en' | |
$translator | ?Translator = null | |
$options | array<string, mixed> = [] | e.g. attachment_max_bytes, attachments_max_total_bytes |
$messageLocale | ?string = null |
hasCountry()#
public function hasCountry(string $code): boolWhether a country pack with $code, e.g. "DE", takes part in the run, leading or for the buyer's country.
| Parameter | Type | Description |
|---|---|---|
$code | string |
- Returns
bool
intOption()#
public function intOption(string $key, int $default): intThe option $key as an integer, e.g. "attachment_max_bytes"; $default when it is not set or not an integer.
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$default | int |
- Returns
int
leadingCountry()#
public function leadingCountry(): ?stringCode of the leading country pack (the seller's country), e.g. "DE"; null without country packs.
- Returns
?string
messageLocale()#
public function messageLocale(): stringLanguage 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): mixedThe option $key of the run, e.g. "syntax" while the XML of a syntax is checked; $default when it is not set or null.
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$default | mixed = null |
- Returns
mixed
profileIs()#
public function profileIs(string ...$keys): boolWhether the profile's key is one of $keys, e.g. "xrechnung" or "xrechnung-extension".
| Parameter | Type | Description |
|---|---|---|
...$keys | string |
- Returns
bool
translator()#
public function translator(): TranslatorTranslator for the messages: the one given to this context, otherwise the shared one of Translations::translator().
- Returns
Translator