Skip to content

Commit

Permalink
Fix parsing elements
Browse files Browse the repository at this point in the history
  • Loading branch information
ben221199 committed Jan 14, 2022
1 parent 1f3f7bc commit 5635e06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Objects/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public static function fromXML(string $xml){
$simpleXML = new SimpleXMLElement($xml);

$channel = new static;
$channel->order = Order::fromXML($simpleXML->xpath('order')[0]->asXML());
$orderXML = $simpleXML->xpath('order')[0] ?? null;
$channel->order = $orderXML?Order::fromXML($orderXML->asXML()):null;
return $channel;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Objects/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public static function fromXML(string $xml){
$order->status_code = (string) $simpleXML->xpath('status_code')[0];
$order->status_description = (string) $simpleXML->xpath('status_description')[0];
$order->price = floatval((string) $simpleXML->xpath('price')[0]);
$order->details = Details::fromXML($simpleXML->xpath('details')[0]->asXML());
$detailsXML = $simpleXML->xpath('details')[0] ?? null;
$order->details = $detailsXML?Details::fromXML($detailsXML->asXML()):null;
$order->order_complete = boolval((string) $simpleXML->xpath('order_complete')[0]);
$order->done = boolval((string) $simpleXML->xpath('done')[0]);
return $order;
Expand Down

0 comments on commit 5635e06

Please sign in to comment.