ResponseCore

Container for all response-related methods.

Defined (1)

The class is defined in the following location(s).

/lib/SNS/lib/requestcore/requestcore.class.php  
  1. class ResponseCore 
  2. /** 
  3. * Stores the HTTP header information. 
  4. */ 
  5. public $header; 
  6.  
  7. /** 
  8. * Stores the SimpleXML response. 
  9. */ 
  10. public $body; 
  11.  
  12. /** 
  13. * Stores the HTTP response code. 
  14. */ 
  15. public $status; 
  16.  
  17. /** 
  18. * Constructs a new instance of this class. 
  19. * @param array $header (Required) Associative array of HTTP headers (typically returned by <RequestCore::get_response_header()>). 
  20. * @param string $body (Required) XML-formatted response from AWS. 
  21. * @param integer $status (Optional) HTTP response status code from the request. 
  22. * @return object Contains an <php:array> `header` property (HTTP headers as an associative array), a <php:SimpleXMLElement> or <php:string> `body` property, and an <php:integer> `status` code. 
  23. */ 
  24. public function __construct($header, $body, $status = null) 
  25. $this->header = $header; 
  26. $this->body = $body; 
  27. $this->status = $status; 
  28.  
  29. return $this; 
  30.  
  31. /** 
  32. * Did we receive the status code we expected? 
  33. * @param integer|array $codes (Optional) The status code(s) to expect. Pass an <php:integer> for a single acceptable value, or an <php:array> of integers for multiple acceptable values. 
  34. * @return boolean Whether we received the expected status code or not. 
  35. */ 
  36. public function isOK($codes = array(200, 201, 204, 206)) 
  37. if (is_array($codes)) 
  38. return in_array($this->status, $codes); 
  39.  
  40. return $this->status === $codes;