Completed
Pull Request — 1.11.x (#1599)
by José
28:19
created

Requests_Exception_Transport_cURL::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 9
nc 8
nop 4
dl 0
loc 16
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
class Requests_Exception_Transport_cURL extends Requests_Exception_Transport {
4
5
	const EASY = 'cURLEasy';
6
	const MULTI = 'cURLMulti';
7
	const SHARE = 'cURLShare';
8
9
	/**
10
	 * cURL error code
11
	 *
12
	 * @var integer
13
	 */
14
	protected $code = -1;
15
16
	/**
17
	 * Which type of cURL error
18
	 *
19
	 * EASY|MULTI|SHARE
20
	 *
21
	 * @var string
22
	 */
23
	protected $type = 'Unknown';
24
25
	/**
26
	 * Clear text error message
27
	 *
28
	 * @var string
29
	 */
30
	protected $reason = 'Unknown';
31
32
	public function __construct($message, $type, $data = null, $code = 0) {
33
		if ($type !== null) {
34
			$this->type = $type;
35
		}
36
37
		if ($code !== null) {
38
			$this->code = $code;
39
		}
40
41
		if ($message !== null) {
42
			$this->reason = $message;
43
		}
44
45
		$message = sprintf('%d %s', $this->code, $this->reason);
46
		parent::__construct($message, $this->type, $data, $this->code);
47
	}
48
49
	/**
50
	 * Get the error message
51
	 */
52
	public function getReason() {
53
		return $this->reason;
54
	}
55
56
}
57