From a3f131f72b8cf49f04ff2ad9515a9d12e3d3d910 Mon Sep 17 00:00:00 2001 From: Okan Date: Fri, 21 Jun 2024 16:03:08 +0300 Subject: [PATCH] Added static constructor for Invoice model. --- src/Models/Invoice.php | 9 +++++++-- tests/Http/SendInvoicesTest.php | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Models/Invoice.php b/src/Models/Invoice.php index 96c1436..cb5ce7a 100644 --- a/src/Models/Invoice.php +++ b/src/Models/Invoice.php @@ -36,6 +36,11 @@ class Invoice extends Type 'otherTransportDetails' => TransportDetail::class, ]; + public static function make(array $attributes = []): self + { + return new Invoice($attributes); + } + /** * Συμπληρώνεται από την Υπηρεσία. * @@ -341,11 +346,11 @@ public function toXml(bool $asInvoicesDoc = false): string { $writer = new InvoicesDocWriter(); $fullXml = $writer->asXML(new InvoicesDoc($this)); - + if ($asInvoicesDoc) { return $fullXml; } - + $doc = $writer->getDomDocument(); return $doc->saveXML($doc->getElementsByTagName('invoice')->item(0)); } diff --git a/tests/Http/SendInvoicesTest.php b/tests/Http/SendInvoicesTest.php index 72ef263..8a55bdc 100644 --- a/tests/Http/SendInvoicesTest.php +++ b/tests/Http/SendInvoicesTest.php @@ -79,7 +79,7 @@ public function test_it_sends_invoices_using_invoices_doc() $invoicesDoc = new InvoicesDoc([new Invoice(), new Invoice()]); $invoicesDoc->add(new Invoice()); - $invoicesDoc->add(new Invoice()); + $invoicesDoc->add(Invoice::make()); $invoicesDoc->add(new Invoice()); $sendInvoices = new SendInvoices();