@@ -25,8 +25,10 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @param array $data Dictionary/map to convert to case-insensitive |
27 | 27 | */ |
28 | - public function __construct(array $data = array()) { |
|
29 | - foreach ($data as $key => $value) { |
|
28 | + public function __construct(array $data = array()) |
|
29 | + { |
|
30 | + foreach ($data as $key => $value) |
|
31 | + { |
|
30 | 32 | $this->offsetSet($key, $value); |
31 | 33 | } |
32 | 34 | } |
@@ -37,7 +39,8 @@ discard block |
||
37 | 39 | * @param string $key Item key |
38 | 40 | * @return boolean Does the item exist? |
39 | 41 | */ |
40 | - public function offsetExists($key) { |
|
42 | + public function offsetExists($key) |
|
43 | + { |
|
41 | 44 | $key = strtolower($key); |
42 | 45 | return isset($this->data[$key]); |
43 | 46 | } |
@@ -48,9 +51,11 @@ discard block |
||
48 | 51 | * @param string $key Item key |
49 | 52 | * @return string Item value |
50 | 53 | */ |
51 | - public function offsetGet($key) { |
|
54 | + public function offsetGet($key) |
|
55 | + { |
|
52 | 56 | $key = strtolower($key); |
53 | - if (!isset($this->data[$key])) { |
|
57 | + if (!isset($this->data[$key])) |
|
58 | + { |
|
54 | 59 | return null; |
55 | 60 | } |
56 | 61 | |
@@ -65,8 +70,10 @@ discard block |
||
65 | 70 | * @param string $key Item name |
66 | 71 | * @param string $value Item value |
67 | 72 | */ |
68 | - public function offsetSet($key, $value) { |
|
69 | - if ($key === null) { |
|
73 | + public function offsetSet($key, $value) |
|
74 | + { |
|
75 | + if ($key === null) |
|
76 | + { |
|
70 | 77 | throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); |
71 | 78 | } |
72 | 79 | |
@@ -79,7 +86,8 @@ discard block |
||
79 | 86 | * |
80 | 87 | * @param string $key |
81 | 88 | */ |
82 | - public function offsetUnset($key) { |
|
89 | + public function offsetUnset($key) |
|
90 | + { |
|
83 | 91 | unset($this->data[strtolower($key)]); |
84 | 92 | } |
85 | 93 | |
@@ -88,7 +96,8 @@ discard block |
||
88 | 96 | * |
89 | 97 | * @return ArrayIterator |
90 | 98 | */ |
91 | - public function getIterator() { |
|
99 | + public function getIterator() |
|
100 | + { |
|
92 | 101 | return new ArrayIterator($this->data); |
93 | 102 | } |
94 | 103 | |
@@ -97,7 +106,8 @@ discard block |
||
97 | 106 | * |
98 | 107 | * @return array Header data |
99 | 108 | */ |
100 | - public function getAll() { |
|
109 | + public function getAll() |
|
110 | + { |
|
101 | 111 | return $this->data; |
102 | 112 | } |
103 | 113 | } |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | * @package Requests |
13 | 13 | * @subpackage Utilities |
14 | 14 | */ |
15 | -class Requests_Utility_FilteredIterator extends ArrayIterator { |
|
15 | +class Requests_Utility_FilteredIterator extends ArrayIterator |
|
16 | +{ |
|
16 | 17 | /** |
17 | 18 | * Callback to run as a filter |
18 | 19 | * |
@@ -26,7 +27,8 @@ discard block |
||
26 | 27 | * @param array $data |
27 | 28 | * @param callable $callback Callback to be called on each value |
28 | 29 | */ |
29 | - public function __construct($data, $callback) { |
|
30 | + public function __construct($data, $callback) |
|
31 | + { |
|
30 | 32 | parent::__construct($data); |
31 | 33 | |
32 | 34 | $this->callback = $callback; |
@@ -37,7 +39,8 @@ discard block |
||
37 | 39 | * |
38 | 40 | * @return string |
39 | 41 | */ |
40 | - public function current() { |
|
42 | + public function current() |
|
43 | + { |
|
41 | 44 | $value = parent::current(); |
42 | 45 | $value = call_user_func($this->callback, $value); |
43 | 46 | return $value; |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class Requests_Exception_Transport_cURL extends Requests_Exception_Transport { |
|
3 | +class Requests_Exception_Transport_cURL extends Requests_Exception_Transport |
|
4 | +{ |
|
4 | 5 | |
5 | 6 | const EASY = 'cURLEasy'; |
6 | 7 | const MULTI = 'cURLMulti'; |
@@ -29,16 +30,20 @@ discard block |
||
29 | 30 | */ |
30 | 31 | protected $reason = 'Unknown'; |
31 | 32 | |
32 | - public function __construct($message, $type, $data = null, $code = 0) { |
|
33 | - if ($type !== null) { |
|
33 | + public function __construct($message, $type, $data = null, $code = 0) |
|
34 | + { |
|
35 | + if ($type !== null) |
|
36 | + { |
|
34 | 37 | $this->type = $type; |
35 | 38 | } |
36 | 39 | |
37 | - if ($code !== null) { |
|
40 | + if ($code !== null) |
|
41 | + { |
|
38 | 42 | $this->code = $code; |
39 | 43 | } |
40 | 44 | |
41 | - if ($message !== null) { |
|
45 | + if ($message !== null) |
|
46 | + { |
|
42 | 47 | $this->reason = $message; |
43 | 48 | } |
44 | 49 | |
@@ -49,7 +54,8 @@ discard block |
||
49 | 54 | /** |
50 | 55 | * Get the error message |
51 | 56 | */ |
52 | - public function getReason() { |
|
57 | + public function getReason() |
|
58 | + { |
|
53 | 59 | return $this->reason; |
54 | 60 | } |
55 | 61 |
@@ -1,5 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class Requests_Exception_Transport extends Requests_Exception { |
|
3 | +class Requests_Exception_Transport extends Requests_Exception |
|
4 | +{ |
|
4 | 5 | |
5 | 6 | } |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | * |
11 | 11 | * @package Requests |
12 | 12 | */ |
13 | -class Requests_Exception_HTTP extends Requests_Exception { |
|
13 | +class Requests_Exception_HTTP extends Requests_Exception |
|
14 | +{ |
|
14 | 15 | /** |
15 | 16 | * HTTP status code |
16 | 17 | * |
@@ -34,8 +35,10 @@ discard block |
||
34 | 35 | * @param string|null $reason Reason phrase |
35 | 36 | * @param mixed $data Associated data |
36 | 37 | */ |
37 | - public function __construct($reason = null, $data = null) { |
|
38 | - if ($reason !== null) { |
|
38 | + public function __construct($reason = null, $data = null) |
|
39 | + { |
|
40 | + if ($reason !== null) |
|
41 | + { |
|
39 | 42 | $this->reason = $reason; |
40 | 43 | } |
41 | 44 | |
@@ -46,7 +49,8 @@ discard block |
||
46 | 49 | /** |
47 | 50 | * Get the status message |
48 | 51 | */ |
49 | - public function getReason() { |
|
52 | + public function getReason() |
|
53 | + { |
|
50 | 54 | return $this->reason; |
51 | 55 | } |
52 | 56 | |
@@ -56,13 +60,16 @@ discard block |
||
56 | 60 | * @param int|bool $code HTTP status code, or false if unavailable |
57 | 61 | * @return string Exception class name to use |
58 | 62 | */ |
59 | - public static function get_class($code) { |
|
60 | - if (!$code) { |
|
63 | + public static function get_class($code) |
|
64 | + { |
|
65 | + if (!$code) |
|
66 | + { |
|
61 | 67 | return 'Requests_Exception_HTTP_Unknown'; |
62 | 68 | } |
63 | 69 | |
64 | 70 | $class = sprintf('Requests_Exception_HTTP_%d', $code); |
65 | - if (class_exists($class)) { |
|
71 | + if (class_exists($class)) |
|
72 | + { |
|
66 | 73 | return $class; |
67 | 74 | } |
68 | 75 |
@@ -10,7 +10,8 @@ |
||
10 | 10 | * |
11 | 11 | * @package Requests |
12 | 12 | */ |
13 | -class Requests_Exception_HTTP_414 extends Requests_Exception_HTTP { |
|
13 | +class Requests_Exception_HTTP_414 extends Requests_Exception_HTTP |
|
14 | +{ |
|
14 | 15 | /** |
15 | 16 | * HTTP status code |
16 | 17 | * |
@@ -10,7 +10,8 @@ |
||
10 | 10 | * |
11 | 11 | * @package Requests |
12 | 12 | */ |
13 | -class Requests_Exception_HTTP_408 extends Requests_Exception_HTTP { |
|
13 | +class Requests_Exception_HTTP_408 extends Requests_Exception_HTTP |
|
14 | +{ |
|
14 | 15 | /** |
15 | 16 | * HTTP status code |
16 | 17 | * |
@@ -12,7 +12,8 @@ |
||
12 | 12 | * @see https://tools.ietf.org/html/rfc6585 |
13 | 13 | * @package Requests |
14 | 14 | */ |
15 | -class Requests_Exception_HTTP_511 extends Requests_Exception_HTTP { |
|
15 | +class Requests_Exception_HTTP_511 extends Requests_Exception_HTTP |
|
16 | +{ |
|
16 | 17 | /** |
17 | 18 | * HTTP status code |
18 | 19 | * |
@@ -12,7 +12,8 @@ |
||
12 | 12 | * @see https://tools.ietf.org/html/rfc6585 |
13 | 13 | * @package Requests |
14 | 14 | */ |
15 | -class Requests_Exception_HTTP_428 extends Requests_Exception_HTTP { |
|
15 | +class Requests_Exception_HTTP_428 extends Requests_Exception_HTTP |
|
16 | +{ |
|
16 | 17 | /** |
17 | 18 | * HTTP status code |
18 | 19 | * |