Requests_Exception_HTTP_Unknown::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
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 {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Coding Style introduced by
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
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
}