Skip to content

API reference / Quittio \ Core \ View

MandatoryFieldGuard

final class in quittio/core

Quittio\Core\View\MandatoryFieldGuard · Source

Checks after rendering that the template printed all mandatory values.

A custom template could omit mandatory information (e.g. the VAT identifier); then PDF and XML would differ in content. Access keys are view model paths:

  • "[]" stands for every index: "vatRows[].amount" requires the amount of every VAT row;
  • "&" combines paths that must all be printed, "|" separates alternatives;
  • a path counts only where the view model has a value: paths of null values and empty lists are not required, and a field whose alternatives all have no value is skipped.

Only printed leaf values count (see ViewNode).

Constants#

ConstantValueDescription
MODE_EXCEPTION'exception'
MODE_LOG'log'
MODE_OFF'off'

Methods#

MethodDescription
->__construct()
::address()The address of a party: all address lines, or street, postcode and city.
::baseFields()Fields every invoice PDF must show, independent of the country.
->check()
::notePath()View model path of the first note that matches, wherever the view model lists it: "legalNotes[i]" for regulatory, legal and tax notes, otherwise "notes[i].content|notes[i].html".

__construct()#

public function __construct(
    string $mode = self::MODE_EXCEPTION,
    ?LoggerInterface $logger = null,
)
ParameterTypeDescription
$modestring = self::MODE_EXCEPTION
$logger?Psr\Log\LoggerInterface = null

address()#

public static function address(string $party): string

static

The address of a party: all address lines, or street, postcode and city.

ParameterTypeDescription
$partystring
Returns
string

baseFields()#

public static function baseFields(InvoiceData $invoice): MandatoryFieldList

static

Fields every invoice PDF must show, independent of the country.

ParameterTypeDescription
$invoiceInvoiceData
Returns
MandatoryFieldList

check()#

public function check(MandatoryFieldList $fields, AccessLog $log): list<MandatoryField>
ParameterTypeDescription
$fieldsMandatoryFieldList
$logAccessLog
Returns
list<MandatoryField> – fields that were not printed

notePath()#

public static function notePath(InvoiceData $invoice, callable $matches): ?string

static

View model path of the first note that matches, wherever the view model lists it: "legalNotes[i]" for regulatory, legal and tax notes, otherwise "notes[i].content|notes[i].html".

ParameterTypeDescription
$invoiceInvoiceData
$matchescallable
Returns
?string

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