Unknown.php 867 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Exception for unknown status responses
  4. *
  5. * @package Requests
  6. */
  7. /**
  8. * Exception for unknown status responses
  9. *
  10. * @package Requests
  11. */
  12. class Requests_Exception_HTTP_Unknown extends Requests_Exception_HTTP {
  13. /**
  14. * HTTP status code
  15. *
  16. * @var integer|bool Code if available, false if an error occurred
  17. */
  18. protected $code = 0;
  19. /**
  20. * Reason phrase
  21. *
  22. * @var string
  23. */
  24. protected $reason = 'Unknown';
  25. /**
  26. * Create a new exception
  27. *
  28. * If `$data` is an instance of {@see Requests_Response}, uses the status
  29. * code from it. Otherwise, sets as 0
  30. *
  31. * @param string|null $reason Reason phrase
  32. * @param mixed $data Associated data
  33. */
  34. public function __construct($reason = null, $data = null) {
  35. if ($data instanceof Requests_Response) {
  36. $this->code = $data->status_code;
  37. }
  38. parent::__construct($reason, $data);
  39. }
  40. }