PhpRulesDriver
in package
implements
ValidationDriver
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.
Table of Contents
Interfaces
- ValidationDriver
- A validation driver checks one or more levels (PHP rules, XSD, KoSIT, veraPDF, …).
Methods
- __construct() : mixed
- knownCodes() : array<int, 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.
- levels() : array<int, ValidationLevel>
- name() : string
- overrides() : RuleOverrides
- The rule overrides of this driver.
- rules() : array<int, Rule>
- The rules for the subject after the overrides: the built-in rules, those of the profile and the country packs, then the additional rules.
- supports() : bool
- Whether the driver can run for the subject (e.g. XML drivers need generated XML).
- validate() : ValidationResult
- withLevels() : self
- The same driver (additional rules, VAT identifier verifier, overrides) with other levels.
- withOverrides() : self
- The same driver with other rule overrides (rules switched off, re-rated or replaced).
- withVatIdVerifier() : self
- The same driver with an online VAT identifier check (e.g. VIES).
Methods
__construct()
public
__construct([array<int, Rule> $additionalRules = [] ][, VatIdVerifier|null $vatIdVerifier = null ][, array<int, ValidationLevel> $levels = [ValidationLevel::L1, ValidationLevel::L2, ValidationLevel::L3, ValidationLevel::L7] ][, RuleOverrides $overrides = new RuleOverrides() ]) : mixed
Parameters
- $additionalRules : array<int, Rule> = []
- $vatIdVerifier : VatIdVerifier|null = null
- $levels : array<int, ValidationLevel> = [ValidationLevel::L1, ValidationLevel::L2, ValidationLevel::L3, ValidationLevel::L7]
-
levels to run; L7 can be switched off
- $overrides : RuleOverrides = new RuleOverrides()
-
rules switched off, re-rated or replaced by code
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.
public
knownCodes(iterable<string|int, Profile> $profiles, iterable<string|int, CountryPack> $packs) : array<int, string>
Parameters
- $profiles : iterable<string|int, Profile>
- $packs : iterable<string|int, CountryPack>
Return values
array<int, string>levels()
public
levels() : array<int, ValidationLevel>
Return values
array<int, ValidationLevel>name()
public
name() : string
Return values
stringoverrides()
The rule overrides of this driver.
public
overrides() : RuleOverrides
Return values
RuleOverridesrules()
The rules for the subject after the overrides: the built-in rules, those of the profile and the country packs, then the additional rules.
public
rules(ValidationSubject $subject) : array<int, Rule>
Parameters
- $subject : ValidationSubject
Return values
array<int, Rule>supports()
Whether the driver can run for the subject (e.g. XML drivers need generated XML).
public
supports(ValidationSubject $subject) : bool
Parameters
- $subject : ValidationSubject
Return values
boolvalidate()
public
validate(ValidationSubject $subject) : ValidationResult
Parameters
- $subject : ValidationSubject
Return values
ValidationResultwithLevels()
The same driver (additional rules, VAT identifier verifier, overrides) with other levels.
public
withLevels(array<int, ValidationLevel> $levels) : self
Parameters
- $levels : array<int, ValidationLevel>
Return values
selfwithOverrides()
The same driver with other rule overrides (rules switched off, re-rated or replaced).
public
withOverrides(RuleOverrides $overrides) : self
Parameters
- $overrides : RuleOverrides
Return values
selfwithVatIdVerifier()
The same driver with an online VAT identifier check (e.g. VIES).
public
withVatIdVerifier(VatIdVerifier|null $verifier) : self
Parameters
- $verifier : VatIdVerifier|null