Response.php 844 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Twilio\Http;
  3. class Response {
  4. protected $headers;
  5. protected $content;
  6. protected $statusCode;
  7. public function __construct($statusCode, $content, $headers = array()) {
  8. $this->statusCode = $statusCode;
  9. $this->content = $content;
  10. $this->headers = $headers;
  11. }
  12. /**
  13. * @return mixed
  14. */
  15. public function getContent() {
  16. return json_decode($this->content, true);
  17. }
  18. /**
  19. * @return mixed
  20. */
  21. public function getStatusCode() {
  22. return $this->statusCode;
  23. }
  24. public function getHeaders() {
  25. return $this->headers;
  26. }
  27. public function ok() {
  28. return $this->getStatusCode() < 400;
  29. }
  30. public function __toString() {
  31. return '[Response] HTTP ' . $this->getStatusCode() . ' ' . $this->content;
  32. }
  33. }