API reference / Quittio \ Core \ Reading
InvoiceReader
final class in quittio/core
Quittio\Core\Reading\InvoiceReader · Source
Reads e-invoices from XML or PDF.
Detects the syntax and profile, keeps the declared totals and reports differences to a recalculation instead of correcting them silently.
Constants#
| Constant | Value | Description |
|---|---|---|
NS_ZUGFERD_1 | 'urn:ferd:CrossIndustryDocument:invoice:1p0' | Namespace of ZUGFeRD 1.0, which is recognised but not supported. |
Methods#
| Method | Description |
|---|---|
->__construct() | |
::defaultReaders() | |
->read() | Reads the content (bytes) of an XML or PDF e-invoice. |
->readFile() | Reads an XML or PDF e-invoice from a local file. |
->withReader() | A copy that also tries $reader after the readers so far, e.g. for a national format. |
__construct()#
public function __construct(
list<FormatReader>|null $readers = null,
?ProfileRegistry $profiles = null,
TotalsCalculator $calculator = new \Quittio\Core\Calculation\En16931Calculator(),
EmbeddedXmlExtractor $pdfExtractor = new \Quittio\Core\Pdf\PdfEmbeddedFileExtractor(),
int $maxXmlBytes = \Quittio\Core\Xml\XmlSecurity::DEFAULT_MAX_BYTES,
)| Parameter | Type | Description |
|---|---|---|
$readers | list<FormatReader>|null = null | |
$profiles | ?ProfileRegistry = null | |
$calculator | TotalsCalculator = new \Quittio\Core\Calculation\En16931Calculator() | |
$pdfExtractor | EmbeddedXmlExtractor = new \Quittio\Core\Pdf\PdfEmbeddedFileExtractor() | |
$maxXmlBytes | int = \Quittio\Core\Xml\XmlSecurity::DEFAULT_MAX_BYTES |
defaultReaders()#
public static function defaultReaders(): list<FormatReader>- Returns
list<FormatReader>
read()#
public function read(string $content): ReadResultReads the content (bytes) of an XML or PDF e-invoice.
The argument is always treated as content, never as a file name; use readFile() for paths.
| Parameter | Type | Description |
|---|---|---|
$content | string |
- Returns
ReadResult- Throws
UnsafeXmlException– when the XML is too large, not well-formed or not allowed (DOCTYPE, limits)- Throws
PdfException– when the PDF is too large, encrypted, malformed or exceeds a limit- Throws
UnreadableInvoiceException– for an unknown format, ZUGFeRD 1.0 or a PDF without an embedded invoice
readFile()#
public function readFile(string $path): ReadResultReads an XML or PDF e-invoice from a local file.
| Parameter | Type | Description |
|---|---|---|
$path | string |
- Returns
ReadResult- Throws
UnsafeXmlException– when the XML is too large, not well-formed or not allowed (DOCTYPE, limits)- Throws
PdfException– when the PDF is too large, encrypted, malformed or exceeds a limit- Throws
UnreadableInvoiceException– for an unknown format, ZUGFeRD 1.0, a PDF without an embedded invoice, or a file that does not exist, is not readable or is too large
withReader()#
public function withReader(FormatReader $reader): selfA copy that also tries $reader after the readers so far, e.g. for a national format.
| Parameter | Type | Description |
|---|---|---|
$reader | FormatReader |
- Returns
self