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#
| Property | Type | Description |
|---|---|---|
$allowOfficial readonly | bool | |
$disabled readonly | list<string> | codes or prefixes ending with "*" whose rules and findings are dropped |
$replacements readonly | array<string, Rule> | rules that replace the rule with the code of the key |
$severities readonly | array<string, Severity> | severity of the findings per code or prefix |
Methods#
| Method | Description |
|---|---|
->__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,
)| Parameter | Type | Description |
|---|---|---|
$disabled | list<string> = [] | codes or prefixes ending with "*" whose rules and findings are dropped |
$severities | array<string, Severity> = [] | severity of the findings per code or prefix |
$replacements | array<string, Rule> = [] | rules that replace the rule with the code of the key |
$allowOfficial | bool = 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.
| Parameter | Type | Description |
|---|---|---|
$rules | list<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.
| Parameter | Type | Description |
|---|---|---|
$messages | list<ValidationMessage> |
- Returns
list<ValidationMessage>
fromArray()#
public static function fromArray(array<array-key, mixed> $config): selfFrom the configuration keys disabled (list of codes), severity (code => error, warning or info) and allow_official.
| Parameter | Type | Description |
|---|---|---|
$config | array<array-key, mixed> |
- Returns
self- Throws
ConfigurationException– for an unknown severity or an official rule without allow_official
isDisabled()#
public function isDisabled(string $code): boolWhether findings with this code are dropped.
| Parameter | Type | Description |
|---|---|---|
$code | string |
- Returns
bool
isEmpty()#
public function isEmpty(): boolWhether nothing is disabled, re-rated or replaced.
- Returns
bool
matches()#
public static function matches(string $pattern, string $code): boolWhether a pattern matches a code: exactly, or by prefix with a trailing "*".
| Parameter | Type | Description |
|---|---|---|
$pattern | string | |
$code | string |
- Returns
bool
merge()#
public function merge(self $other): selfThese overrides with those of $other on top: $other wins for the same code.
| Parameter | Type | Description |
|---|---|---|
$other | self |
- 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>