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