Status304.php
5 months ago
Status305.php
5 months ago
Status306.php
5 months ago
Status400.php
5 months ago
Status401.php
5 months ago
Status402.php
5 months ago
Status403.php
5 months ago
Status404.php
5 months ago
Status405.php
5 months ago
Status406.php
5 months ago
Status407.php
5 months ago
Status408.php
5 months ago
Status409.php
5 months ago
Status410.php
5 months ago
Status411.php
5 months ago
Status412.php
5 months ago
Status413.php
5 months ago
Status414.php
5 months ago
Status415.php
5 months ago
Status416.php
5 months ago
Status417.php
5 months ago
Status418.php
5 months ago
Status428.php
5 months ago
Status429.php
5 months ago
Status431.php
5 months ago
Status500.php
5 months ago
Status501.php
5 months ago
Status502.php
5 months ago
Status503.php
5 months ago
Status504.php
5 months ago
Status505.php
5 months ago
Status511.php
5 months ago
StatusUnknown.php
5 months ago
StatusUnknown.php
50 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Exception for unknown status responses |
| 4 | * |
| 5 | * @package Requests\Exceptions |
| 6 | */ |
| 7 | |
| 8 | namespace AmeliaVendor\WpOrg\Requests\Exception\Http; |
| 9 | |
| 10 | use AmeliaVendor\WpOrg\Requests\Exception\Http; |
| 11 | use AmeliaVendor\WpOrg\Requests\Response; |
| 12 | |
| 13 | /** |
| 14 | * Exception for unknown status responses |
| 15 | * |
| 16 | * @package Requests\Exceptions |
| 17 | */ |
| 18 | final class StatusUnknown extends Http { |
| 19 | /** |
| 20 | * HTTP status code |
| 21 | * |
| 22 | * @var integer|bool Code if available, false if an error occurred |
| 23 | */ |
| 24 | protected $code = 0; |
| 25 | |
| 26 | /** |
| 27 | * Reason phrase |
| 28 | * |
| 29 | * @var string |
| 30 | */ |
| 31 | protected $reason = 'Unknown'; |
| 32 | |
| 33 | /** |
| 34 | * Create a new exception |
| 35 | * |
| 36 | * If `$data` is an instance of {@see \WpOrg\Requests\Response}, uses the status |
| 37 | * code from it. Otherwise, sets as 0 |
| 38 | * |
| 39 | * @param string|null $reason Reason phrase |
| 40 | * @param mixed $data Associated data |
| 41 | */ |
| 42 | public function __construct($reason = null, $data = null) { |
| 43 | if ($data instanceof Response) { |
| 44 | $this->code = (int) $data->status_code; |
| 45 | } |
| 46 | |
| 47 | parent::__construct($reason, $data); |
| 48 | } |
| 49 | } |
| 50 |