Source for file ErrorResponse.php

Documentation is available at ErrorResponse.php

  1. <?php
  2. /** 
  3.  *  PHP Version 5
  4.  *
  5.  *  @category    Amazon
  6.  *  @package     Amazon_SimpleDB
  7.  *  @copyright   Copyright 2008 Amazon Technologies, Inc.
  8.  *  @link        http://aws.amazon.com
  9.  *  @license     http://aws.amazon.com/apache2.0  Apache License, Version 2.0
  10.  *  @version     2007-11-07
  11.  */
  12. /******************************************************************************* 
  13.  *    __  _    _  ___ 
  14.  *   (  )( \/\/ )/ __)
  15.  *   /__\ \    / \__ \
  16.  *  (_)(_) \/\/  (___/
  17.  * 
  18.  *  Amazon Simple DB PHP5 Library
  19.  *  Generated: Thu Aug 28 06:20:51 PDT 2008
  20.  * 
  21.  */
  22.  
  23. /**
  24.  *  @see Amazon_SimpleDB_Model
  25.  */
  26. require_once ('Amazon/SimpleDB/Model.php');  
  27.  
  28.     
  29.  
  30. /**
  31.  * Amazon_SimpleDB_Model_ErrorResponse
  32.  * 
  33.  * Properties:
  34.  * <ul>
  35.  * 
  36.  * <li>Error: Amazon_SimpleDB_Model_Error</li>
  37.  * <li>RequestId: string</li>
  38.  *
  39.  * </ul>
  40.  */ 
  41. {
  42.  
  43.  
  44.     /**
  45.      * Construct new Amazon_SimpleDB_Model_ErrorResponse
  46.      * 
  47.      * @param mixed $data DOMElement or Associative Array to construct from.
  48.      * 
  49.      *  Valid properties:
  50.      *  <ul>
  51.      * 
  52.      *  <li>Error: Amazon_SimpleDB_Model_Error</li>
  53.      *  <li>RequestId: string</li>
  54.      *
  55.      *  </ul>
  56.      */
  57.     public function __construct($data null)
  58.     {
  59.         $this->_fields = array (
  60.         'Error' => array('FieldValue' => array()'FieldType' => array('Amazon_SimpleDB_Model_Error')),
  61.         'RequestId' => array('FieldValue' => null'FieldType' => 'string'),
  62.         );
  63.         parent::__construct($data);
  64.     }
  65.  
  66.        
  67.     /**
  68.      * Construct Amazon_SimpleDB_Model_ErrorResponse from XML string
  69.      * 
  70.      * @param string $xml XML string to construct from
  71.      * @return Amazon_SimpleDB_Model_ErrorResponse 
  72.      */
  73.     public static function fromXML($xml)
  74.     {
  75.         $dom new DOMDocument();
  76.         $dom->loadXML($xml);
  77.         $xpath new DOMXPath($dom);
  78.         $xpath->registerNamespace('a''http://sdb.amazonaws.com/doc/2007-11-07/');
  79.         $response $xpath->query('//a:${ActionName}Response');
  80.         if ($response->length == 1{
  81.             return new Amazon_SimpleDB_Model_ErrorResponse(($response->item(0)))
  82.         else {
  83.             throw new Exception ("Unable to construct Amazon_SimpleDB_Model_ErrorResponse from provided XML. 
  84.                                   Make sure that ${ActionName}Response is a root element");
  85.         }
  86.           
  87.     }
  88.     
  89.     /**
  90.      * Gets the value of the Error.
  91.      * 
  92.      * @return array of Error Error
  93.      */
  94.     public function getError(
  95.     {
  96.         return $this->_fields['Error']['FieldValue'];
  97.     }
  98.  
  99.     /**
  100.      * Sets the value of the Error.
  101.      * 
  102.      * @param mixed Error or an array of Error Error
  103.      * @return this instance
  104.      */
  105.     public function setError($error
  106.     {
  107.         if (!$this->_isNumericArray($error)) {
  108.             $error =  array ($error);    
  109.         }
  110.         $this->_fields['Error']['FieldValue'$error;
  111.         return $this;
  112.     }
  113.  
  114.  
  115.     /**
  116.      * Sets single or multiple values of Error list via variable number of arguments.
  117.      * For example, to set the list with two elements, simply pass two values as arguments to this function
  118.      * <code>withError($error1, $error2)</code>
  119.      * 
  120.      * @param Error  $errorArgs one or more Error
  121.      * @return Amazon_SimpleDB_Model_ErrorResponse  instance
  122.      */
  123.     public function withError($errorArgs)
  124.     {
  125.         foreach (func_get_args(as $error{
  126.             $this->_fields['Error']['FieldValue'][$error;
  127.         }
  128.         return $this;
  129.     }   
  130.  
  131.  
  132.  
  133.     /**
  134.      * Checks if Error list is non-empty
  135.      * 
  136.      * @return bool true if Error list is non-empty
  137.      */
  138.     public function isSetError()
  139.     {
  140.         return count ($this->_fields['Error']['FieldValue']0;
  141.     }
  142.  
  143.     /**
  144.      * Gets the value of the RequestId property.
  145.      * 
  146.      * @return string RequestId
  147.      */
  148.     public function getRequestId(
  149.     {
  150.         return $this->_fields['RequestId']['FieldValue'];
  151.     }
  152.  
  153.     /**
  154.      * Sets the value of the RequestId property.
  155.      * 
  156.      * @param string RequestId
  157.      * @return this instance
  158.      */
  159.     public function setRequestId($value
  160.     {
  161.         $this->_fields['RequestId']['FieldValue'$value;
  162.         return $this;
  163.     }
  164.  
  165.     /**
  166.      * Sets the value of the RequestId and returns this instance
  167.      * 
  168.      * @param string $value RequestId
  169.      * @return Amazon_SimpleDB_Model_ErrorResponse instance
  170.      */
  171.     public function withRequestId($value)
  172.     {
  173.         $this->setRequestId($value);
  174.         return $this;
  175.     }
  176.  
  177.  
  178.     /**
  179.      * Checks if RequestId is set
  180.      * 
  181.      * @return bool true if RequestId  is set
  182.      */
  183.     public function isSetRequestId()
  184.     {
  185.         return !is_null($this->_fields['RequestId']['FieldValue']);
  186.     }
  187.  
  188.  
  189.  
  190.     /**
  191.      * XML Representation for this object
  192.      * 
  193.      * @return string XML for this object
  194.      */
  195.     public function toXML(
  196.     {
  197.         $xml "";
  198.         $xml .= "<ErrorResponse xmlns=\"http://sdb.amazonaws.com/doc/2007-11-07/\">";
  199.         $xml .= $this->_toXMLFragment();
  200.         $xml .= "</ErrorResponse>";
  201.         return $xml;
  202.     }
  203.  
  204. }

Documentation generated on Thu, 28 Aug 2008 06:35:47 -0700 by phpDocumentor 1.4.2