API reference / Quittio \ Core \ View
InvoiceViewModel
final class in quittio/core · extends ViewNode
Quittio\Core\View\InvoiceViewModel · Source
The only object templates receive. Every value is available formatted ($value->formatted or {{ $value }}) and raw ($value->raw).
Templates contain no calculation logic; all values are calculated beforehand.
The nodes below are typed (Quittio\Core\View\Model): IDEs and static analysis know that
$invoice->seller->address->lines is a ViewList
Properties#
| Property | Type | Description |
|---|---|---|
$data protected | array<string|int, mixed> | from ViewNode |
$log protected | AccessLog | from ViewNode |
$path protected | string | from ViewNode |
Methods#
| Method | Description |
|---|---|
->__construct() | |
->__get() | |
->__isset() | |
->accessLog() | Log of the fields the template read, which the mandatory field guard checks after rendering. |
->count() | Number of entries of this node, e.g. lines of a list. Not recorded as read. |
->getIterator() | Items are read (and recorded) one by one while the template loops over them. |
->isEmpty() | Whether this node has no entries. Not recorded as read. |
->jsonSerialize() | Encodes the plain values like toArray(), which counts as reading every value below this node. |
->label() | Translated label; per invoice overrides from the presentation data win. |
->offsetExists() | Whether $offset holds a value other than null, e.g. isset($node['vatId']). Not recorded as read. |
->offsetGet() | Reads $offset like property access, e.g. $node['name']: a nested node for a list or group, otherwise the value, which is recorded as read unless it is null. |
->offsetSet() | Always throws LogicException: the view model is read-only. |
->offsetUnset() | Always throws LogicException: the view model is read-only. |
->read() | |
->title() | Document title (e.g. "Invoice", "Credit note") for PDF metadata and file names. |
->toArray() | Plain values, e.g. for implode(); counts as reading every value below this node. |
__construct()#
public function __construct(
array<string, mixed> $data,
?AccessLog $log = null,
array<string, string> $aliases = [],
)| Parameter | Type | Description |
|---|---|---|
$data | array<string, mixed> | |
$log | ?AccessLog = null | |
$aliases | array<string, string> = [] | view model nodes that stand for others, e.g. issuer => seller |
__get()#
public function __get(string $name): mixed| Parameter | Type | Description |
|---|---|---|
$name | string |
- Returns
mixed
__isset()#
public function __isset(string $name): bool| Parameter | Type | Description |
|---|---|---|
$name | string |
- Returns
bool
accessLog()#
public function accessLog(): AccessLogLog of the fields the template read, which the mandatory field guard checks after rendering.
- Returns
AccessLog
count()#
public function count(): intNumber of entries of this node, e.g. lines of a list. Not recorded as read.
- Returns
int
getIterator()#
public function getIterator(): TraversableItems are read (and recorded) one by one while the template loops over them.
- Returns
Traversable
isEmpty()#
public function isEmpty(): boolWhether this node has no entries. Not recorded as read.
- Returns
bool
jsonSerialize()#
public function jsonSerialize(): mixedEncodes the plain values like toArray(), which counts as reading every value below this node.
- Returns
mixed
label()#
public function label(string $key, array<string, string> $replace = []): stringTranslated label; per invoice overrides from the presentation data win.
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$replace | array<string, string> = [] |
- Returns
string
offsetExists()#
public function offsetExists(mixed $offset): boolWhether $offset holds a value other than null, e.g. isset($node['vatId']). Not recorded as read.
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
- Returns
bool
offsetGet()#
public function offsetGet(mixed $offset): mixedReads $offset like property access, e.g. $node['name']: a nested node for a list or group, otherwise the value, which is recorded as read unless it is null.
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
- Returns
mixed
offsetSet()#
public function offsetSet(mixed $offset, mixed $value): voidAlways throws LogicException: the view model is read-only.
| Parameter | Type | Description |
|---|---|---|
$offset | mixed | |
$value | mixed |
offsetUnset()#
public function offsetUnset(mixed $offset): voidAlways throws LogicException: the view model is read-only.
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
read()#
protected function read(string|int $key): mixed| Parameter | Type | Description |
|---|---|---|
$key | string|int |
- Returns
mixed
title()#
public function title(): stringDocument title (e.g. "Invoice", "Credit note") for PDF metadata and file names.
- Returns
string
toArray()#
public function toArray(): array<string|int, mixed>Plain values, e.g. for implode(); counts as reading every value below this node.
- Returns
array<string|int, mixed>