From 07adeac9615b58f94fd01cdb4a428428656f487c Mon Sep 17 00:00:00 2001 From: Fabian Blechschmidt Date: Fri, 24 May 2024 10:28:18 +0200 Subject: [PATCH] Add static factory for existing files --- src/ZugferdDocumentPdfBuilder.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ZugferdDocumentPdfBuilder.php b/src/ZugferdDocumentPdfBuilder.php index ba115287..64bef365 100644 --- a/src/ZugferdDocumentPdfBuilder.php +++ b/src/ZugferdDocumentPdfBuilder.php @@ -38,6 +38,17 @@ class ZugferdDocumentPdfBuilder extends ZugferdDocumentPdfBuilderAbstract */ private $xmlDataCache = ""; + /** + * @see self::__construct + */ + public static function fromPdfFile(ZugferdDocumentBuilder $documentBuilder, string $pdfData): self + { + if (!is_file($pdfData)) { + throw new \InvalidArgumentException("The given PDF file does not exist."); + } + return new self($documentBuilder, $pdfData); + } + /** * Constructor *