Skip to content

Commit 5635e06

Browse files
committed
Fix parsing elements
1 parent 1f3f7bc commit 5635e06

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Objects/Channel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public static function fromXML(string $xml){
1616
$simpleXML = new SimpleXMLElement($xml);
1717

1818
$channel = new static;
19-
$channel->order = Order::fromXML($simpleXML->xpath('order')[0]->asXML());
19+
$orderXML = $simpleXML->xpath('order')[0] ?? null;
20+
$channel->order = $orderXML?Order::fromXML($orderXML->asXML()):null;
2021
return $channel;
2122
}
2223

src/Objects/Order.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ public static function fromXML(string $xml){
7070
$order->status_code = (string) $simpleXML->xpath('status_code')[0];
7171
$order->status_description = (string) $simpleXML->xpath('status_description')[0];
7272
$order->price = floatval((string) $simpleXML->xpath('price')[0]);
73-
$order->details = Details::fromXML($simpleXML->xpath('details')[0]->asXML());
73+
$detailsXML = $simpleXML->xpath('details')[0] ?? null;
74+
$order->details = $detailsXML?Details::fromXML($detailsXML->asXML()):null;
7475
$order->order_complete = boolval((string) $simpleXML->xpath('order_complete')[0]);
7576
$order->done = boolval((string) $simpleXML->xpath('done')[0]);
7677
return $order;

0 commit comments

Comments
 (0)