-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
namespace Ben221199\Oxxa\API\Objects; | ||
|
||
use SimpleXMLElement; | ||
|
||
class Channel{ | ||
|
||
/**@var Order $order*/ | ||
private $order; | ||
|
||
public function getOrder(){ | ||
return $this->order; | ||
} | ||
|
||
public static function fromXML(string $xml){ | ||
$simpleXML = new SimpleXMLElement($xml); | ||
|
||
$channel = new static; | ||
$channel->order = Order::fromXML($simpleXML->xpath('order')[0]->asXML()); | ||
return $channel; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
namespace Ben221199\Oxxa\API\Objects; | ||
|
||
use SimpleXMLElement; | ||
|
||
class Details{ | ||
|
||
/**@var SimpleXMLElement $_simpleXML*/ | ||
private $_simpleXML; | ||
|
||
public function getValue(){ | ||
return (string) $this->_simpleXML; | ||
} | ||
|
||
public function getElementsByName($name){ | ||
return $this->_simpleXML->xpath($name); | ||
} | ||
|
||
public static function fromXML(string $xml){ | ||
$simpleXML = new SimpleXMLElement($xml); | ||
|
||
$details = new static; | ||
$details->_simpleXML = $simpleXML; | ||
return $details; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
namespace Ben221199\Oxxa\API\Objects; | ||
|
||
use SimpleXMLElement; | ||
|
||
class Order{ | ||
|
||
/**@var int $order_id*/ | ||
private $order_id; | ||
|
||
/**@var string $command*/ | ||
private $command; | ||
|
||
/**@var string $status_code*/ | ||
private $status_code; | ||
|
||
/**@var string $status_description*/ | ||
private $status_description; | ||
|
||
/**@var float $price*/ | ||
private $price; | ||
|
||
/**@var Details $details*/ | ||
private $details; | ||
|
||
/**@var bool $order_complete*/ | ||
private $order_complete; | ||
|
||
/**@var bool $done*/ | ||
private $done; | ||
|
||
public static function fromXML(string $xml){ | ||
$simpleXML = new SimpleXMLElement($xml); | ||
|
||
$order = new static; | ||
$order->order_id = intval((string) $simpleXML->xpath('order_id')[0]); | ||
$order->command = (string) $simpleXML->xpath('command')[0]; | ||
$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()); | ||
$order->order_complete = boolval((string) $simpleXML->xpath('order_complete')[0]); | ||
$order->done = boolval((string) $simpleXML->xpath('done')[0]); | ||
return $order; | ||
} | ||
|
||
} |