Skip to content

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#

MethodDescription
->__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()Returns "php", the name of this check in the validation.levels configuration.
->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()Runs the rules() of the configured levels against the invoice data, after loading the message catalogs of the country packs. Applies the overrides to the findings and reports identical findings once.
->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(),
)
ParameterTypeDescription
$additionalRuleslist<Rule> = []
$vatIdVerifier?VatIdVerifier = null
$levelslist<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
$overridesRuleOverrides = 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.

ParameterTypeDescription
$profilesiterable<Profile>
$packsiterable<CountryPack>
Returns
list<string>

levels()#

public function levels(): array
Returns
array

name()#

public function name(): string

Returns "php", the name of this check in the validation.levels configuration.

Returns
string

overrides()#

public function overrides(): RuleOverrides

The 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.

ParameterTypeDescription
$subjectValidationSubject
Returns
list<Rule>

supports()#

public function supports(ValidationSubject $subject): bool
ParameterTypeDescription
$subjectValidationSubject
Returns
bool

validate()#

public function validate(ValidationSubject $subject): ValidationResult

Runs the rules() of the configured levels against the invoice data, after loading the message catalogs of the country packs. Applies the overrides to the findings and reports identical findings once.

ParameterTypeDescription
$subjectValidationSubject
Returns
ValidationResult

withLevels()#

public function withLevels(list<ValidationLevel> $levels): self

The same driver (additional rules, VAT identifier verifier, overrides) with other levels.

ParameterTypeDescription
$levelslist<ValidationLevel>
Returns
self

withOverrides()#

public function withOverrides(RuleOverrides $overrides): self

The same driver with other rule overrides (rules switched off, re-rated or replaced).

ParameterTypeDescription
$overridesRuleOverrides
Returns
self

withVatIdVerifier()#

public function withVatIdVerifier(?VatIdVerifier $verifier): self

The same driver with an online VAT identifier check (e.g. VIES).

ParameterTypeDescription
$verifier?VatIdVerifier
Returns
self

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