Skip to content

API reference / Quittio \ Core \ Validation

RuleOverrides

final readonly class in quittio/core

Quittio\Core\Validation\RuleOverrides · Source

Changes to the PHP rules by rule code: rules switched off, findings with another severity and rules replaced by own implementations. Codes match exactly or, with a trailing "*", by prefix (e.g. "DE-USTG-*"). The overrides apply to the PHP rules only; the findings of the XSD schema, KoSIT and veraPDF are never changed.

The rules of EN 16931 (BR-) and Peppol (PEPPOL-) are official: switching them off, changing their severity or replacing them needs $allowOfficial, because an invoice that breaks them is rejected by the receiver.

Properties#

PropertyTypeDescription
$allowOfficial readonlybool
$disabled readonlylist<string>codes or prefixes ending with "*" whose rules and findings are dropped
$replacements readonlyarray<string, Rule>rules that replace the rule with the code of the key
$severities readonlyarray<string, Severity>severity of the findings per code or prefix

Methods#

MethodDescription
->__construct()
->apply()The rules without the disabled ones, replaced rules exchanged in place.
->applyToMessages()The findings without those of disabled codes, with the configured severities. Rules may report other codes than their own (e.g. QUITTIO-PROFILE-REQUIRED), so the findings are filtered as well.
::fromArray()From the configuration keys disabled (list of codes), severity (code => error, warning or info) and allow_official.
->isDisabled()Whether findings with this code are dropped.
->isEmpty()Whether nothing is disabled, re-rated or replaced.
::matches()Whether a pattern matches a code: exactly, or by prefix with a trailing "*".
->merge()These overrides with those of $other on top: $other wins for the same code.
->patterns()Every pattern of these overrides, e.g. to check them against the known rule codes.

__construct()#

public function __construct(
    list<string> $disabled = [],
    array<string, Severity> $severities = [],
    array<string, Rule> $replacements = [],
    bool $allowOfficial = false,
)
ParameterTypeDescription
$disabledlist<string> = []codes or prefixes ending with "*" whose rules and findings are dropped
$severitiesarray<string, Severity> = []severity of the findings per code or prefix
$replacementsarray<string, Rule> = []rules that replace the rule with the code of the key
$allowOfficialbool = false
Throws
ConfigurationException – when an official rule is changed without $allowOfficial or a pattern is empty

apply()#

public function apply(list<Rule> $rules): list<Rule>

The rules without the disabled ones, replaced rules exchanged in place.

ParameterTypeDescription
$ruleslist<Rule>
Returns
list<Rule>

applyToMessages()#

public function applyToMessages(
    list<ValidationMessage> $messages,
): list<ValidationMessage>

The findings without those of disabled codes, with the configured severities. Rules may report other codes than their own (e.g. QUITTIO-PROFILE-REQUIRED), so the findings are filtered as well.

ParameterTypeDescription
$messageslist<ValidationMessage>
Returns
list<ValidationMessage>

fromArray()#

public static function fromArray(array<array-key, mixed> $config): self

static

From the configuration keys disabled (list of codes), severity (code => error, warning or info) and allow_official.

ParameterTypeDescription
$configarray<array-key, mixed>
Returns
self
Throws
ConfigurationException – for an unknown severity or an official rule without allow_official

isDisabled()#

public function isDisabled(string $code): bool

Whether findings with this code are dropped.

ParameterTypeDescription
$codestring
Returns
bool

isEmpty()#

public function isEmpty(): bool

Whether nothing is disabled, re-rated or replaced.

Returns
bool

matches()#

public static function matches(string $pattern, string $code): bool

static

Whether a pattern matches a code: exactly, or by prefix with a trailing "*".

ParameterTypeDescription
$patternstring
$codestring
Returns
bool

merge()#

public function merge(self $other): self

These overrides with those of $other on top: $other wins for the same code.

ParameterTypeDescription
$otherself
Returns
self

patterns()#

public function patterns(): list<string>

Every pattern of these overrides, e.g. to check them against the known rule codes.

Returns
list<string>

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