Created
May 2, 2013 07:47
-
-
Save rtuin/5500754 to your computer and use it in GitHub Desktop.
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
<?php | |
class Bundles implements ResponseClassInterface | |
{ | |
protected $bundles = array(); | |
public function addBundle($bundle) | |
{ | |
$this->bundles[] = $bundle; | |
} | |
/** | |
* Create a response model object from a completed command | |
* | |
* @param OperationCommand $command That serialized the request | |
* | |
* @return self | |
*/ | |
public static function fromCommand(OperationCommand $command) | |
{ | |
$bundlesObject = new self(); | |
$xml = new \DOMDocument(); | |
$xml->loadXML($command->getResponse()->getBody(true)); | |
$xpath = new \DOMXPath($xml); | |
foreach ($xpath->query('/bundles/bundle/@href') as $bundle) { | |
$bundlesObject->addBundle($bundle->value); | |
} | |
return $bundlesObject; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment