Skip to content

API reference / Quittio \ Core \ Rendering

RenderedInvoice

final class in quittio/core

Quittio\Core\Rendering\RenderedInvoice · Source

Result of a render run. With several formats, every format is reachable via {@see self::as()}; all share the same calculation.

Methods#

MethodDescription
->__construct()
->as()The result for another format of the same run.
->contents()The main output: PDF, otherwise XML, HTML or JSON.
->data()The calculated invoice data of the run (totals, VAT breakdown, due date).
->extension()Extension of the main output (contents()): pdf, xml, html or json.
->filename()File name of the main output, from the configured pattern; $extension replaces the extension of the main output.
->format()Key of the format of this result, e.g. "zugferd".
->formats()
->hashes()SHA-256 hashes of the outputs, e.g. for archiving.
->hasPdf()Whether this format produced a PDF.
->hasXml()Whether this format produced XML (also the XML embedded in a PDF).
->html()The rendered template, as mPDF received it.
->json()The invoice as JSON (InvoiceData::toJson()).
->mimeType()MIME type of the main output (contents()).
->pdf()The PDF.
->profile()Profile of the XML; null for formats without XML.
->save()Writes the main output. A directory as target uses {@see self::filename()}.
->validation()Validation result of this format; in the mode "warn" it may contain errors, empty in the mode "off".
->xml()The e-invoice XML, also the one embedded in the PDF.

__construct()#

public function __construct(
    InvoiceData $data,
    string $format,
    ?Profile $profile,
    ValidationResult $validation,
    string $filenamePattern,
    ?string $xml = null,
    ?string $pdf = null,
    ?string $html = null,
    ?string $json = null,
)
ParameterTypeDescription
$dataInvoiceData
$formatstring
$profile?Profile
$validationValidationResult
$filenamePatternstringfile name with the placeholder {ext}
$xml?string = null
$pdf?string = null
$html?string = null
$json?string = null

as()#

public function as(string $format): self

The result for another format of the same run.

ParameterTypeDescription
$formatstring
Returns
self

contents()#

public function contents(): string

The main output: PDF, otherwise XML, HTML or JSON.

Returns
string

data()#

public function data(): InvoiceData

The calculated invoice data of the run (totals, VAT breakdown, due date).

Returns
InvoiceData

extension()#

public function extension(): string

Extension of the main output (contents()): pdf, xml, html or json.

Returns
string

filename()#

public function filename(?string $extension = null): string

File name of the main output, from the configured pattern; $extension replaces the extension of the main output.

ParameterTypeDescription
$extension?string = null
Returns
string

format()#

public function format(): string

Key of the format of this result, e.g. "zugferd".

Returns
string

formats()#

public function formats(): list<string>
Returns
list<string>

hashes()#

public function hashes(): array<string, string>

SHA-256 hashes of the outputs, e.g. for archiving.

Returns
array<string, string>

hasPdf()#

public function hasPdf(): bool

Whether this format produced a PDF.

Returns
bool

hasXml()#

public function hasXml(): bool

Whether this format produced XML (also the XML embedded in a PDF).

Returns
bool

html()#

public function html(): string

The rendered template, as mPDF received it.

Returns
string
Throws
LogicException – when the format produced no HTML

json()#

public function json(): string

The invoice as JSON (InvoiceData::toJson()).

Returns
string

mimeType()#

public function mimeType(): string

MIME type of the main output (contents()).

Returns
string

pdf()#

public function pdf(): string

The PDF.

Returns
string
Throws
LogicException – when the format produces no PDF (see hasPdf())

profile()#

public function profile(): ?Profile

Profile of the XML; null for formats without XML.

Returns
?Profile

save()#

public function save(string $path): string

Writes the main output. A directory as target uses {@see self::filename()}.

ParameterTypeDescription
$pathstring
Returns
string – the written path

validation()#

public function validation(): ValidationResult

Validation result of this format; in the mode "warn" it may contain errors, empty in the mode "off".

Returns
ValidationResult

xml()#

public function xml(): string

The e-invoice XML, also the one embedded in the PDF.

Returns
string
Throws
LogicException – when the format produces no XML (see hasXml())

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