Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: added empty string instead of null #231

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/DomDocuments/ArticlesDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function addArticle(Article $article)
if (is_bool($nodeValue)) {
$nodeValue = ($nodeValue) ? 'true' : 'false';
}
$node = $this->createTextNode($nodeValue);
$node = $this->createTextNode($nodeValue ?? '');

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

// Make the actual element and assign the text node
$element = $this->createElement($tag);
Expand Down
16 changes: 8 additions & 8 deletions src/DomDocuments/CustomersDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function addCustomer(Customer $customer): void

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

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

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

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

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

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

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

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

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

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

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

// Make the actual elements and assign the text nodes
$field2Element = $this->createElement('field2');
Expand Down
6 changes: 3 additions & 3 deletions src/DomDocuments/InvoicesDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function addInvoice(Invoice $invoice)
$customer = $invoice->getCustomer();

// <customer>
$customerNode = $this->createTextNode($customer->getCode());
$customerNode = $this->createTextNode($customer->getCode() ?? '');
$customerElement = $this->createElement('customer');
$customerElement->appendChild($customerNode);
$headerElement->appendChild($customerElement);
Expand Down Expand Up @@ -78,7 +78,7 @@ public function addInvoice(Invoice $invoice)

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

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

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

if ($node->textContent === "") {
continue;
Expand Down
12 changes: 6 additions & 6 deletions src/DomDocuments/SuppliersDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function addSupplier(Supplier $supplier)
foreach ($supplierTags as $tag => $method) {

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

// Make the actual element and assign the node
$element = $this->createElement($tag);
Expand Down Expand Up @@ -107,7 +107,7 @@ public function addSupplier(Supplier $supplier)
if (is_bool($nodeValue)) {
$nodeValue = ($nodeValue) ? 'true' : 'false';
}
$node = $this->createTextNode($nodeValue);
$node = $this->createTextNode($nodeValue ?? '');

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

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

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

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

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

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

// Make the actual elements and assign the text nodes
$field2Element = $this->createElement('field2');
Expand Down
2 changes: 1 addition & 1 deletion src/DomDocuments/TransactionsDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public function addTransaction(BaseTransaction $transaction)
}

if ($transactionLine->getDescription() !== null) {
$descriptionNode = $this->createTextNode($transactionLine->getDescription());
$descriptionNode = $this->createTextNode($transactionLine->getDescription() ?? '');
$descriptionElement = $this->createElement('description');
$descriptionElement->appendChild($descriptionNode);
$lineElement->appendChild($descriptionElement);
Expand Down
Loading