Skip to content

Commit 11c4ccc

Browse files
committed
Fix: added empty string instead of null
1 parent 5339d6a commit 11c4ccc

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

src/DomDocuments/ArticlesDocument.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function addArticle(Article $article)
8585
if (is_bool($nodeValue)) {
8686
$nodeValue = ($nodeValue) ? 'true' : 'false';
8787
}
88-
$node = $this->createTextNode($nodeValue);
88+
$node = $this->createTextNode($nodeValue ?? '');
8989

9090
// Make the actual element and assign the node
9191
$element = $this->createElement($tag);
@@ -138,7 +138,7 @@ public function addArticle(Article $article)
138138
// Go through each line element and use the assigned method
139139
foreach ($lineTags as $tag => $method) {
140140
// Make the text node for the method value
141-
$node = $this->createTextNode($line->$method());
141+
$node = $this->createTextNode($line->$method() ?? '');
142142

143143
// Make the actual element and assign the text node
144144
$element = $this->createElement($tag);

src/DomDocuments/CustomersDocument.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function addCustomer(Customer $customer): void
6060

6161
if($value = $customer->$method()) {
6262
// Make text node for method value
63-
$node = $this->createTextNode($value);
63+
$node = $this->createTextNode($value ?? '');
6464

6565
// Make the actual element and assign the node
6666
$element = $this->createElement($tag);
@@ -96,7 +96,7 @@ public function addCustomer(Customer $customer): void
9696
if (is_bool($nodeValue)) {
9797
$nodeValue = ($nodeValue) ? 'true' : 'false';
9898
}
99-
$node = $this->createTextNode($nodeValue);
99+
$node = $this->createTextNode($nodeValue ?? '');
100100

101101
// Make the actual element and assign the node
102102
$element = $this->createElement($tag);
@@ -126,7 +126,7 @@ public function addCustomer(Customer $customer): void
126126
foreach ($collectMandateTags as $tag => $method) {
127127

128128
// Make the text node for the method value
129-
$node = $this->createTextNode($this->getValueFromCallback([$collectMandate, $method]));
129+
$node = $this->createTextNode($this->getValueFromCallback([$collectMandate, $method]) ?? '');
130130

131131
// Make the actual element and assign the node
132132
$element = $this->createElement($tag);
@@ -179,7 +179,7 @@ public function addCustomer(Customer $customer): void
179179
if (is_bool($nodeValue)) {
180180
$nodeValue = ($nodeValue) ? 'true' : 'false';
181181
}
182-
$node = $this->createTextNode($nodeValue);
182+
$node = $this->createTextNode($nodeValue ?? '');
183183

184184
// Make the actual element and assign the node
185185
$element = $this->createElement($tag);
@@ -231,7 +231,7 @@ public function addCustomer(Customer $customer): void
231231
foreach ($addressTags as $tag => $method) {
232232

233233
// Make the text node for the method value
234-
$node = $this->createTextNode($address->$method());
234+
$node = $this->createTextNode($address->$method() ?? '');
235235

236236
// Make the actual element and assign the text node
237237
$element = $this->createElement($tag);
@@ -279,7 +279,7 @@ public function addCustomer(Customer $customer): void
279279
foreach ($bankTags as $tag => $method) {
280280

281281
// Make the text node for the method value
282-
$node = $this->createTextNode($bank->$method());
282+
$node = $this->createTextNode($bank->$method() ?? '');
283283

284284
// Make the actual element and assign the text node
285285
$element = $this->createElement($tag);
@@ -292,8 +292,8 @@ public function addCustomer(Customer $customer): void
292292
// Bank address fields
293293

294294
// Make the text nodes for the bank address fields
295-
$field2Node = $this->createTextNode($bank->getAddressField2());
296-
$field3Node = $this->createTextNode($bank->getAddressField3());
295+
$field2Node = $this->createTextNode($bank->getAddressField2() ?? '');
296+
$field3Node = $this->createTextNode($bank->getAddressField3() ?? '');
297297

298298
// Make the actual elements and assign the text nodes
299299
$field2Element = $this->createElement('field2');

src/DomDocuments/InvoicesDocument.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function addInvoice(Invoice $invoice)
4848
$customer = $invoice->getCustomer();
4949

5050
// <customer>
51-
$customerNode = $this->createTextNode($customer->getCode());
51+
$customerNode = $this->createTextNode($customer->getCode() ?? '');
5252
$customerElement = $this->createElement('customer');
5353
$customerElement->appendChild($customerNode);
5454
$headerElement->appendChild($customerElement);
@@ -78,7 +78,7 @@ public function addInvoice(Invoice $invoice)
7878

7979
if(null !== $value) {
8080
// Make text node for method value
81-
$node = $this->createTextNode($value);
81+
$node = $this->createTextNode($value ?? '');
8282

8383
// Make the actual element and assign the node
8484
$element = $this->createElement($tag);
@@ -122,7 +122,7 @@ public function addInvoice(Invoice $invoice)
122122
foreach ($lineTags as $tag => $method) {
123123

124124
// Make text node for method value
125-
$node = $this->createTextNode($this->getValueFromCallback([$line, $method]));
125+
$node = $this->createTextNode($this->getValueFromCallback([$line, $method]) ?? '');
126126

127127
if ($node->textContent === "") {
128128
continue;

src/DomDocuments/SuppliersDocument.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function addSupplier(Supplier $supplier)
7272
foreach ($supplierTags as $tag => $method) {
7373

7474
// Make text node for method value
75-
$node = $this->createTextNode($supplier->$method());
75+
$node = $this->createTextNode($supplier->$method() ?? '');
7676

7777
// Make the actual element and assign the node
7878
$element = $this->createElement($tag);
@@ -107,7 +107,7 @@ public function addSupplier(Supplier $supplier)
107107
if (is_bool($nodeValue)) {
108108
$nodeValue = ($nodeValue) ? 'true' : 'false';
109109
}
110-
$node = $this->createTextNode($nodeValue);
110+
$node = $this->createTextNode($nodeValue ?? '');
111111

112112
// Make the actual element and assign the node
113113
$element = $this->createElement($tag);
@@ -165,7 +165,7 @@ public function addSupplier(Supplier $supplier)
165165
foreach ($addressTags as $tag => $method) {
166166

167167
// Make the text node for the method value
168-
$node = $this->createTextNode($address->$method());
168+
$node = $this->createTextNode($address->$method() ?? '');
169169

170170
// Make the actual element and assign the text node
171171
$element = $this->createElement($tag);
@@ -212,7 +212,7 @@ public function addSupplier(Supplier $supplier)
212212
foreach ($bankTags as $tag => $method) {
213213

214214
// Make the text node for the method value
215-
$node = $this->createTextNode($bank->$method());
215+
$node = $this->createTextNode($bank->$method() ?? '');
216216

217217
// Make the actual element and assign the text node
218218
$element = $this->createElement($tag);
@@ -225,8 +225,8 @@ public function addSupplier(Supplier $supplier)
225225
// Bank address fields
226226

227227
// Make the text nodes for the bank address fields
228-
$field2Node = $this->createTextNode($bank->getAddressField2());
229-
$field3Node = $this->createTextNode($bank->getAddressField3());
228+
$field2Node = $this->createTextNode($bank->getAddressField2() ?? '');
229+
$field3Node = $this->createTextNode($bank->getAddressField3() ?? '');
230230

231231
// Make the actual elements and assign the text nodes
232232
$field2Element = $this->createElement('field2');

src/DomDocuments/TransactionsDocument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function addTransaction(BaseTransaction $transaction)
234234
}
235235

236236
if ($transactionLine->getDescription() !== null) {
237-
$descriptionNode = $this->createTextNode($transactionLine->getDescription());
237+
$descriptionNode = $this->createTextNode($transactionLine->getDescription() ?? '');
238238
$descriptionElement = $this->createElement('description');
239239
$descriptionElement->appendChild($descriptionNode);
240240
$lineElement->appendChild($descriptionElement);

0 commit comments

Comments
 (0)