Skip to content

Instantly share code, notes, and snippets.

@rtuin
Created May 2, 2013 07:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtuin/5500754 to your computer and use it in GitHub Desktop.
Save rtuin/5500754 to your computer and use it in GitHub Desktop.
<?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