API reference / Quittio \ Core \ Validation \ Drivers
PhpRulesDriver
final class in quittio/core · implements ValidationDriver
Quittio\Core\Validation\Drivers\PhpRulesDriver · Source
Built-in PHP rules: levels L1 (structure), L2 (profile), L3 (business rules) and L7 (plausibility).
Rules of the profile and of the country packs are added per invoice.
Methods#
| Method | Description |
|---|---|
->__construct() | |
->knownCodes() | Every rule and finding code this driver can report with the given profiles and country packs (without the overrides), e.g. to check configured overrides for typing errors. |
->levels() | |
->name() | |
->overrides() | The rule overrides of this driver. |
->rules() | The rules for the subject after the overrides: the built-in rules, those of the profile and the country packs without those the profile replaces (ReplacesRules), then the additional rules. |
->supports() | |
->validate() | |
->withLevels() | The same driver (additional rules, VAT identifier verifier, overrides) with other levels. |
->withOverrides() | The same driver with other rule overrides (rules switched off, re-rated or replaced). |
->withVatIdVerifier() | The same driver with an online VAT identifier check (e.g. VIES). |
__construct()#
public function __construct(
list<Rule> $additionalRules = [],
?VatIdVerifier $vatIdVerifier = null,
list<ValidationLevel> $levels = [\Quittio\Core\Validation\ValidationLevel::L1, \Quittio\Core\Validation\ValidationLevel::L2, \Quittio\Core\Validation\ValidationLevel::L3, \Quittio\Core\Validation\ValidationLevel::L7],
RuleOverrides $overrides = new \Quittio\Core\Validation\RuleOverrides(),
)| Parameter | Type | Description |
|---|---|---|
$additionalRules | list<Rule> = [] | |
$vatIdVerifier | ?VatIdVerifier = null | |
$levels | list<ValidationLevel> = [\Quittio\Core\Validation\ValidationLevel::L1, \Quittio\Core\Validation\ValidationLevel::L2, \Quittio\Core\Validation\ValidationLevel::L3, \Quittio\Core\Validation\ValidationLevel::L7] | levels to run; L7 can be switched off |
$overrides | RuleOverrides = new \Quittio\Core\Validation\RuleOverrides() | rules switched off, re-rated or replaced by code |
knownCodes()#
public function knownCodes(
iterable<Profile> $profiles,
iterable<CountryPack> $packs,
): list<string>Every rule and finding code this driver can report with the given profiles and country packs (without the overrides), e.g. to check configured overrides for typing errors.
| Parameter | Type | Description |
|---|---|---|
$profiles | iterable<Profile> | |
$packs | iterable<CountryPack> |
- Returns
list<string>
levels()#
public function levels(): array- Returns
array
name()#
public function name(): string- Returns
string
overrides()#
public function overrides(): RuleOverridesThe rule overrides of this driver.
- Returns
RuleOverrides
rules()#
public function rules(ValidationSubject $subject): list<Rule>The rules for the subject after the overrides: the built-in rules, those of the profile and the country packs without those the profile replaces (ReplacesRules), then the additional rules.
| Parameter | Type | Description |
|---|---|---|
$subject | ValidationSubject |
- Returns
list<Rule>
supports()#
public function supports(ValidationSubject $subject): bool| Parameter | Type | Description |
|---|---|---|
$subject | ValidationSubject |
- Returns
bool
validate()#
public function validate(ValidationSubject $subject): ValidationResult| Parameter | Type | Description |
|---|---|---|
$subject | ValidationSubject |
- Returns
ValidationResult
withLevels()#
public function withLevels(list<ValidationLevel> $levels): selfThe same driver (additional rules, VAT identifier verifier, overrides) with other levels.
| Parameter | Type | Description |
|---|---|---|
$levels | list<ValidationLevel> |
- Returns
self
withOverrides()#
public function withOverrides(RuleOverrides $overrides): selfThe same driver with other rule overrides (rules switched off, re-rated or replaced).
| Parameter | Type | Description |
|---|---|---|
$overrides | RuleOverrides |
- Returns
self
withVatIdVerifier()#
public function withVatIdVerifier(?VatIdVerifier $verifier): selfThe same driver with an online VAT identifier check (e.g. VIES).
| Parameter | Type | Description |
|---|---|---|
$verifier | ?VatIdVerifier |
- Returns
self