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#
| Method | Description |
|---|---|
->__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,
)| Parameter | Type | Description |
|---|---|---|
$data | InvoiceData | |
$format | string | |
$profile | ?Profile | |
$validation | ValidationResult | |
$filenamePattern | string | file name with the placeholder {ext} |
$xml | ?string = null | |
$pdf | ?string = null | |
$html | ?string = null | |
$json | ?string = null |
as()#
public function as(string $format): selfThe result for another format of the same run.
| Parameter | Type | Description |
|---|---|---|
$format | string |
- Returns
self
contents()#
public function contents(): stringThe main output: PDF, otherwise XML, HTML or JSON.
- Returns
string
data()#
public function data(): InvoiceDataThe calculated invoice data of the run (totals, VAT breakdown, due date).
- Returns
InvoiceData
extension()#
public function extension(): stringExtension of the main output (contents()): pdf, xml, html or json.
- Returns
string
filename()#
public function filename(?string $extension = null): stringFile name of the main output, from the configured pattern; $extension replaces the extension of the main output.
| Parameter | Type | Description |
|---|---|---|
$extension | ?string = null |
- Returns
string
format()#
public function format(): stringKey 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(): boolWhether this format produced a PDF.
- Returns
bool
hasXml()#
public function hasXml(): boolWhether this format produced XML (also the XML embedded in a PDF).
- Returns
bool
html()#
public function html(): stringThe rendered template, as mPDF received it.
- Returns
string- Throws
LogicException– when the format produced no HTML
json()#
public function json(): stringThe invoice as JSON (InvoiceData::toJson()).
- Returns
string
mimeType()#
public function mimeType(): stringMIME type of the main output (contents()).
- Returns
string
pdf()#
public function pdf(): stringThe PDF.
- Returns
string- Throws
LogicException– when the format produces no PDF (see hasPdf())
profile()#
public function profile(): ?ProfileProfile of the XML; null for formats without XML.
- Returns
?Profile
save()#
public function save(string $path): stringWrites the main output. A directory as target uses {@see self::filename()}.
| Parameter | Type | Description |
|---|---|---|
$path | string |
- Returns
string– the written path
validation()#
public function validation(): ValidationResultValidation result of this format; in the mode "warn" it may contain errors, empty in the mode "off".
- Returns
ValidationResult
xml()#
public function xml(): stringThe e-invoice XML, also the one embedded in the PDF.
- Returns
string- Throws
LogicException– when the format produces no XML (see hasXml())