Completed
Push — 1.11.x ( 518476...344d9e )
by José
55:02 queued 28:13
created

Requests_Exception_HTTP_Unknown   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
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
}