@@ -43,12 +43,12 @@ |
||
43 | 43 | |
44 | 44 | protected function stripBom($body) |
45 | 45 | { |
46 | - if ( substr($body,0,3) === "\xef\xbb\xbf" ) // UTF-8 |
|
47 | - $body = substr($body,3); |
|
48 | - else if ( substr($body,0,4) === "\xff\xfe\x00\x00" || substr($body,0,4) === "\x00\x00\xfe\xff" ) // UTF-32 |
|
49 | - $body = substr($body,4); |
|
50 | - else if ( substr($body,0,2) === "\xff\xfe" || substr($body,0,2) === "\xfe\xff" ) // UTF-16 |
|
51 | - $body = substr($body,2); |
|
46 | + if (substr($body, 0, 3) === "\xef\xbb\xbf") // UTF-8 |
|
47 | + $body = substr($body, 3); |
|
48 | + else if (substr($body, 0, 4) === "\xff\xfe\x00\x00" || substr($body, 0, 4) === "\x00\x00\xfe\xff") // UTF-32 |
|
49 | + $body = substr($body, 4); |
|
50 | + else if (substr($body, 0, 2) === "\xff\xfe" || substr($body, 0, 2) === "\xfe\xff") // UTF-16 |
|
51 | + $body = substr($body, 2); |
|
52 | 52 | return $body; |
53 | 53 | } |
54 | 54 | } |
55 | 55 | \ No newline at end of file |
@@ -43,12 +43,16 @@ |
||
43 | 43 | |
44 | 44 | protected function stripBom($body) |
45 | 45 | { |
46 | - if ( substr($body,0,3) === "\xef\xbb\xbf" ) // UTF-8 |
|
46 | + if ( substr($body,0,3) === "\xef\xbb\xbf" ) { |
|
47 | + // UTF-8 |
|
47 | 48 | $body = substr($body,3); |
48 | - else if ( substr($body,0,4) === "\xff\xfe\x00\x00" || substr($body,0,4) === "\x00\x00\xfe\xff" ) // UTF-32 |
|
49 | + } else if ( substr($body,0,4) === "\xff\xfe\x00\x00" || substr($body,0,4) === "\x00\x00\xfe\xff" ) { |
|
50 | + // UTF-32 |
|
49 | 51 | $body = substr($body,4); |
50 | - else if ( substr($body,0,2) === "\xff\xfe" || substr($body,0,2) === "\xfe\xff" ) // UTF-16 |
|
52 | + } else if ( substr($body,0,2) === "\xff\xfe" || substr($body,0,2) === "\xfe\xff" ) { |
|
53 | + // UTF-16 |
|
51 | 54 | $body = substr($body,2); |
55 | + } |
|
52 | 56 | return $body; |
53 | 57 | } |
54 | 58 | } |
55 | 59 | \ No newline at end of file |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | return null; |
20 | 20 | |
21 | 21 | $parsed = array(); |
22 | - $fp = fopen('data://text/plain;base64,' . base64_encode($body), 'r'); |
|
22 | + $fp = fopen('data://text/plain;base64,'.base64_encode($body), 'r'); |
|
23 | 23 | while (($r = fgetcsv($fp)) !== FALSE) { |
24 | 24 | $parsed[] = $r; |
25 | 25 | } |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function serialize($payload) |
37 | 37 | { |
38 | - $fp = fopen('php://temp/maxmemory:'. (6*1024*1024), 'r+'); |
|
38 | + $fp = fopen('php://temp/maxmemory:'.(6 * 1024 * 1024), 'r+'); |
|
39 | 39 | $i = 0; |
40 | 40 | foreach ($payload as $fields) { |
41 | - if($i++ == 0) { |
|
41 | + if ($i++ == 0) { |
|
42 | 42 | fputcsv($fp, array_keys($fields)); |
43 | 43 | } |
44 | 44 | fputcsv($fp, $fields); |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function parse($body) |
17 | 17 | { |
18 | - if (empty($body)) |
|
19 | - return null; |
|
18 | + if (empty($body)) { |
|
19 | + return null; |
|
20 | + } |
|
20 | 21 | |
21 | 22 | $parsed = array(); |
22 | 23 | $fp = fopen('data://text/plain;base64,' . base64_encode($body), 'r'); |
@@ -24,8 +25,9 @@ discard block |
||
24 | 25 | $parsed[] = $r; |
25 | 26 | } |
26 | 27 | |
27 | - if (empty($parsed)) |
|
28 | - throw new \Exception("Unable to parse response as CSV"); |
|
28 | + if (empty($parsed)) { |
|
29 | + throw new \Exception("Unable to parse response as CSV"); |
|
30 | + } |
|
29 | 31 | return $parsed; |
30 | 32 | } |
31 | 33 |
@@ -23,11 +23,13 @@ |
||
23 | 23 | public function parse($body) |
24 | 24 | { |
25 | 25 | $body = $this->stripBom($body); |
26 | - if (empty($body)) |
|
27 | - return null; |
|
26 | + if (empty($body)) { |
|
27 | + return null; |
|
28 | + } |
|
28 | 29 | $parsed = json_decode($body, $this->decode_as_array); |
29 | - if (is_null($parsed) && 'null' !== strtolower($body)) |
|
30 | - throw new \Exception("Unable to parse response as JSON"); |
|
30 | + if (is_null($parsed) && 'null' !== strtolower($body)) { |
|
31 | + throw new \Exception("Unable to parse response as JSON"); |
|
32 | + } |
|
31 | 33 | return $parsed; |
32 | 34 | } |
33 | 35 |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function __construct(array $conf = array()) |
27 | 27 | { |
28 | - $this->namespace = isset($conf['namespace']) ? $conf['namespace'] : ''; |
|
29 | - $this->libxml_opts = isset($conf['libxml_opts']) ? $conf['libxml_opts'] : 0; |
|
28 | + $this->namespace = isset($conf['namespace']) ? $conf['namespace'] : ''; |
|
29 | + $this->libxml_opts = isset($conf['libxml_opts']) ? $conf['libxml_opts'] : 0; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | $xml = new \XMLWriter; |
67 | 67 | $xml->openMemory(); |
68 | - $xml->startDocument('1.0','ISO-8859-1'); |
|
68 | + $xml->startDocument('1.0', 'ISO-8859-1'); |
|
69 | 69 | $this->serialize_node($xml, $payload); |
70 | 70 | return $xml->outputMemory(true); |
71 | 71 | } |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param mixed $node to serialize |
76 | 76 | * @author Ted Zellers |
77 | 77 | */ |
78 | - public function serialize_node(&$xmlw, $node){ |
|
79 | - if (!is_array($node)){ |
|
78 | + public function serialize_node(&$xmlw, $node) { |
|
79 | + if (!is_array($node)) { |
|
80 | 80 | $xmlw->text($node); |
81 | 81 | } else { |
82 | - foreach ($node as $k => $v){ |
|
82 | + foreach ($node as $k => $v) { |
|
83 | 83 | $xmlw->startElement($k); |
84 | 84 | $this->serialize_node($xmlw, $v); |
85 | 85 | $xmlw->endElement(); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $node->appendChild($arrNode); |
113 | 113 | $this->_future_serializeArrayAsXml($value, $arrNode, $dom); |
114 | 114 | } else if (is_bool($value)) { |
115 | - $node->appendChild($dom->createTextNode($value?'TRUE':'FALSE')); |
|
115 | + $node->appendChild($dom->createTextNode($value ? 'TRUE' : 'FALSE')); |
|
116 | 116 | } else { |
117 | 117 | $node->appendChild($dom->createTextNode($value)); |
118 | 118 | } |
@@ -37,11 +37,13 @@ |
||
37 | 37 | public function parse($body) |
38 | 38 | { |
39 | 39 | $body = $this->stripBom($body); |
40 | - if (empty($body)) |
|
41 | - return null; |
|
40 | + if (empty($body)) { |
|
41 | + return null; |
|
42 | + } |
|
42 | 43 | $parsed = simplexml_load_string($body, null, $this->libxml_opts, $this->namespace); |
43 | - if ($parsed === false) |
|
44 | - throw new \Exception("Unable to parse response as XML"); |
|
44 | + if ($parsed === false) { |
|
45 | + throw new \Exception("Unable to parse response as XML"); |
|
46 | + } |
|
45 | 47 | return $parsed; |
46 | 48 | } |
47 | 49 |
@@ -11,17 +11,17 @@ discard block |
||
11 | 11 | { |
12 | 12 | |
13 | 13 | public $body, |
14 | - $raw_body, |
|
15 | - $headers, |
|
16 | - $raw_headers, |
|
17 | - $request, |
|
18 | - $code = 0, |
|
19 | - $content_type, |
|
20 | - $parent_type, |
|
21 | - $charset, |
|
22 | - $meta_data, |
|
23 | - $is_mime_vendor_specific = false, |
|
24 | - $is_mime_personal = false; |
|
14 | + $raw_body, |
|
15 | + $headers, |
|
16 | + $raw_headers, |
|
17 | + $request, |
|
18 | + $code = 0, |
|
19 | + $content_type, |
|
20 | + $parent_type, |
|
21 | + $charset, |
|
22 | + $meta_data, |
|
23 | + $is_mime_vendor_specific = false, |
|
24 | + $is_mime_personal = false; |
|
25 | 25 | |
26 | 26 | private $parsers; |
27 | 27 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | : $this->parent_type; |
105 | 105 | } |
106 | 106 | |
107 | - return Httpful::get($parse_with)->parse($body); |
|
107 | + return Httpful::get($parse_with)->parse($body); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | $this->_interpretHeaders(); |
45 | 45 | |
46 | - $this->body = $this->_parse($body); |
|
46 | + $this->body = $this->_parse($body); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | // If a header appears more than once, it must also be able to |
128 | 128 | // be represented as a single header with a comma-separated |
129 | 129 | // list of values. We transform accordingly. |
130 | - $parse_headers[$key] .= ',' . $value; |
|
130 | + $parse_headers[$key] .= ','.$value; |
|
131 | 131 | } else { |
132 | 132 | $parse_headers[$key] = $value; |
133 | 133 | } |
@@ -138,7 +138,9 @@ |
||
138 | 138 | public function _parseCode($headers) |
139 | 139 | { |
140 | 140 | $end = strpos($headers, "\r\n"); |
141 | - if ($end === false) $end = strlen($headers); |
|
141 | + if ($end === false) { |
|
142 | + $end = strlen($headers); |
|
143 | + } |
|
142 | 144 | $parts = explode(' ', substr($headers, 0, $end)); |
143 | 145 | if (count($parts) < 2 || !is_numeric($parts[1])) { |
144 | 146 | throw new \Exception("Unable to parse response code from HTTP response due to malformed response"); |
@@ -29,25 +29,25 @@ discard block |
||
29 | 29 | const MAX_REDIRECTS_DEFAULT = 25; |
30 | 30 | |
31 | 31 | public $uri, |
32 | - $method = Http::GET, |
|
33 | - $headers = array(), |
|
34 | - $raw_headers = '', |
|
35 | - $strict_ssl = false, |
|
36 | - $content_type, |
|
37 | - $expected_type, |
|
38 | - $additional_curl_opts = array(), |
|
39 | - $auto_parse = true, |
|
40 | - $serialize_payload_method = self::SERIALIZE_PAYLOAD_SMART, |
|
41 | - $username, |
|
42 | - $password, |
|
43 | - $serialized_payload, |
|
44 | - $payload, |
|
45 | - $parse_callback, |
|
46 | - $error_callback, |
|
47 | - $send_callback, |
|
48 | - $follow_redirects = false, |
|
49 | - $max_redirects = self::MAX_REDIRECTS_DEFAULT, |
|
50 | - $payload_serializers = array(); |
|
32 | + $method = Http::GET, |
|
33 | + $headers = array(), |
|
34 | + $raw_headers = '', |
|
35 | + $strict_ssl = false, |
|
36 | + $content_type, |
|
37 | + $expected_type, |
|
38 | + $additional_curl_opts = array(), |
|
39 | + $auto_parse = true, |
|
40 | + $serialize_payload_method = self::SERIALIZE_PAYLOAD_SMART, |
|
41 | + $username, |
|
42 | + $password, |
|
43 | + $serialized_payload, |
|
44 | + $payload, |
|
45 | + $parse_callback, |
|
46 | + $error_callback, |
|
47 | + $send_callback, |
|
48 | + $follow_redirects = false, |
|
49 | + $max_redirects = self::MAX_REDIRECTS_DEFAULT, |
|
50 | + $payload_serializers = array(); |
|
51 | 51 | |
52 | 52 | // Options |
53 | 53 | // private $_options = array( |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | // Curl Handle |
59 | 59 | public $_ch, |
60 | - $_debug; |
|
60 | + $_debug; |
|
61 | 61 | |
62 | 62 | // Template Request object |
63 | 63 | private static $_template; |
@@ -390,9 +390,9 @@ discard block |
||
390 | 390 | $this->payload[$key] = curl_file_create($file, $mimeType); |
391 | 391 | } else { |
392 | 392 | $this->payload[$key] = '@' . $file; |
393 | - if ($mimeType) { |
|
394 | - $this->payload[$key] .= ';type=' . $mimeType; |
|
395 | - } |
|
393 | + if ($mimeType) { |
|
394 | + $this->payload[$key] .= ';type=' . $mimeType; |
|
395 | + } |
|
396 | 396 | } |
397 | 397 | } |
398 | 398 | $this->sendsType(Mime::UPLOAD); |
@@ -813,10 +813,10 @@ discard block |
||
813 | 813 | |
814 | 814 | $request = new Request(); |
815 | 815 | return $request |
816 | - ->_setDefaults() |
|
817 | - ->method($method) |
|
818 | - ->sendsType($mime) |
|
819 | - ->expectsType($mime); |
|
816 | + ->_setDefaults() |
|
817 | + ->method($method) |
|
818 | + ->sendsType($mime) |
|
819 | + ->expectsType($mime); |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | /** |
@@ -389,9 +389,9 @@ discard block |
||
389 | 389 | if (function_exists('curl_file_create')) { |
390 | 390 | $this->payload[$key] = curl_file_create($file, $mimeType); |
391 | 391 | } else { |
392 | - $this->payload[$key] = '@' . $file; |
|
392 | + $this->payload[$key] = '@'.$file; |
|
393 | 393 | if ($mimeType) { |
394 | - $this->payload[$key] .= ';type=' . $mimeType; |
|
394 | + $this->payload[$key] .= ';type='.$mimeType; |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | } |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | public function contentType($mime) |
407 | 407 | { |
408 | 408 | if (empty($mime)) return $this; |
409 | - $this->content_type = Mime::getFullMime($mime); |
|
409 | + $this->content_type = Mime::getFullMime($mime); |
|
410 | 410 | if ($this->isUpload()) { |
411 | 411 | $this->neverSerializePayload(); |
412 | 412 | } |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | { |
456 | 456 | $this->addOnCurlOption(CURLOPT_PROXY, "{$proxy_host}:{$proxy_port}"); |
457 | 457 | $this->addOnCurlOption(CURLOPT_PROXYTYPE, $proxy_type); |
458 | - if (in_array($auth_type, array(CURLAUTH_BASIC,CURLAUTH_NTLM))) { |
|
458 | + if (in_array($auth_type, array(CURLAUTH_BASIC, CURLAUTH_NTLM))) { |
|
459 | 459 | $this->addOnCurlOption(CURLOPT_PROXYAUTH, $auth_type) |
460 | 460 | ->addOnCurlOption(CURLOPT_PROXYUSERPWD, "{$auth_username}:{$auth_password}"); |
461 | 461 | } |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | } |
849 | 849 | |
850 | 850 | if ($this->hasBasicAuth()) { |
851 | - curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->password); |
|
851 | + curl_setopt($ch, CURLOPT_USERPWD, $this->username.':'.$this->password); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | if ($this->hasClientSideCert()) { |
@@ -859,11 +859,11 @@ discard block |
||
859 | 859 | if (!file_exists($this->client_cert)) |
860 | 860 | throw new \Exception('Could not read Client Certificate'); |
861 | 861 | |
862 | - curl_setopt($ch, CURLOPT_SSLCERTTYPE, $this->client_encoding); |
|
863 | - curl_setopt($ch, CURLOPT_SSLKEYTYPE, $this->client_encoding); |
|
864 | - curl_setopt($ch, CURLOPT_SSLCERT, $this->client_cert); |
|
865 | - curl_setopt($ch, CURLOPT_SSLKEY, $this->client_key); |
|
866 | - curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $this->client_passphrase); |
|
862 | + curl_setopt($ch, CURLOPT_SSLCERTTYPE, $this->client_encoding); |
|
863 | + curl_setopt($ch, CURLOPT_SSLKEYTYPE, $this->client_encoding); |
|
864 | + curl_setopt($ch, CURLOPT_SSLCERT, $this->client_cert); |
|
865 | + curl_setopt($ch, CURLOPT_SSLKEY, $this->client_key); |
|
866 | + curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $this->client_passphrase); |
|
867 | 867 | // curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $this->client_cert_passphrase); |
868 | 868 | } |
869 | 869 | |
@@ -983,7 +983,7 @@ discard block |
||
983 | 983 | */ |
984 | 984 | public function buildUserAgent() |
985 | 985 | { |
986 | - $user_agent = 'User-Agent: Httpful/' . Httpful::VERSION . ' (cURL/'; |
|
986 | + $user_agent = 'User-Agent: Httpful/'.Httpful::VERSION.' (cURL/'; |
|
987 | 987 | $curl = \curl_version(); |
988 | 988 | |
989 | 989 | if (isset($curl['version'])) { |
@@ -992,10 +992,10 @@ discard block |
||
992 | 992 | $user_agent .= '?.?.?'; |
993 | 993 | } |
994 | 994 | |
995 | - $user_agent .= ' PHP/'. PHP_VERSION . ' (' . PHP_OS . ')'; |
|
995 | + $user_agent .= ' PHP/'.PHP_VERSION.' ('.PHP_OS.')'; |
|
996 | 996 | |
997 | 997 | if (isset($_SERVER['SERVER_SOFTWARE'])) { |
998 | - $user_agent .= ' ' . \preg_replace('~PHP/[\d\.]+~U', '', |
|
998 | + $user_agent .= ' '.\preg_replace('~PHP/[\d\.]+~U', '', |
|
999 | 999 | $_SERVER['SERVER_SOFTWARE']); |
1000 | 1000 | } else { |
1001 | 1001 | if (isset($_SERVER['TERM_PROGRAM'])) { |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | if ($curlErrorNumber = curl_errno($this->_ch)) { |
1026 | 1026 | $curlErrorString = curl_error($this->_ch); |
1027 | 1027 | $this->_error($curlErrorString); |
1028 | - throw new ConnectionErrorException('Unable to connect to "'.$this->uri.'": ' . $curlErrorNumber . ' ' . $curlErrorString); |
|
1028 | + throw new ConnectionErrorException('Unable to connect to "'.$this->uri.'": '.$curlErrorNumber.' '.$curlErrorString); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | $this->_error('Unable to connect to "'.$this->uri.'".'); |
@@ -71,7 +71,9 @@ discard block |
||
71 | 71 | */ |
72 | 72 | private function __construct($attrs = null) |
73 | 73 | { |
74 | - if (!is_array($attrs)) return; |
|
74 | + if (!is_array($attrs)) { |
|
75 | + return; |
|
76 | + } |
|
75 | 77 | foreach ($attrs as $attr => $value) { |
76 | 78 | $this->$attr = $value; |
77 | 79 | } |
@@ -196,8 +198,9 @@ discard block |
||
196 | 198 | */ |
197 | 199 | public function send() |
198 | 200 | { |
199 | - if (!$this->hasBeenInitialized()) |
|
200 | - $this->_curlPrep(); |
|
201 | + if (!$this->hasBeenInitialized()) { |
|
202 | + $this->_curlPrep(); |
|
203 | + } |
|
201 | 204 | |
202 | 205 | $result = curl_exec($this->_ch); |
203 | 206 | |
@@ -334,7 +337,9 @@ discard block |
||
334 | 337 | */ |
335 | 338 | public function mime($mime) |
336 | 339 | { |
337 | - if (empty($mime)) return $this; |
|
340 | + if (empty($mime)) { |
|
341 | + return $this; |
|
342 | + } |
|
338 | 343 | $this->content_type = $this->expected_type = Mime::getFullMime($mime); |
339 | 344 | if ($this->isUpload()) { |
340 | 345 | $this->neverSerializePayload(); |
@@ -360,7 +365,9 @@ discard block |
||
360 | 365 | */ |
361 | 366 | public function method($method) |
362 | 367 | { |
363 | - if (empty($method)) return $this; |
|
368 | + if (empty($method)) { |
|
369 | + return $this; |
|
370 | + } |
|
364 | 371 | $this->method = $method; |
365 | 372 | return $this; |
366 | 373 | } |
@@ -371,7 +378,9 @@ discard block |
||
371 | 378 | */ |
372 | 379 | public function expects($mime) |
373 | 380 | { |
374 | - if (empty($mime)) return $this; |
|
381 | + if (empty($mime)) { |
|
382 | + return $this; |
|
383 | + } |
|
375 | 384 | $this->expected_type = Mime::getFullMime($mime); |
376 | 385 | return $this; |
377 | 386 | } |
@@ -405,7 +414,9 @@ discard block |
||
405 | 414 | */ |
406 | 415 | public function contentType($mime) |
407 | 416 | { |
408 | - if (empty($mime)) return $this; |
|
417 | + if (empty($mime)) { |
|
418 | + return $this; |
|
419 | + } |
|
409 | 420 | $this->content_type = Mime::getFullMime($mime); |
410 | 421 | if ($this->isUpload()) { |
411 | 422 | $this->neverSerializePayload(); |
@@ -725,15 +736,17 @@ discard block |
||
725 | 736 | |
726 | 737 | // This method also adds the custom header support as described in the |
727 | 738 | // method comments |
728 | - if (count($args) === 0) |
|
729 | - return; |
|
739 | + if (count($args) === 0) { |
|
740 | + return; |
|
741 | + } |
|
730 | 742 | |
731 | 743 | // Strip the sugar. If it leads with "with", strip. |
732 | 744 | // This is okay because: No defined HTTP headers begin with with, |
733 | 745 | // and if you are defining a custom header, the standard is to prefix it |
734 | 746 | // with an "X-", so that should take care of any collisions. |
735 | - if (substr($method, 0, 4) === 'with') |
|
736 | - $method = substr($method, 4); |
|
747 | + if (substr($method, 0, 4) === 'with') { |
|
748 | + $method = substr($method, 4); |
|
749 | + } |
|
737 | 750 | |
738 | 751 | // Precede upper case letters with dashes, uppercase the first letter of method |
739 | 752 | $header = ucwords(implode('-', preg_split('/([A-Z][^A-Z]*)/', $method, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY))); |
@@ -774,11 +787,13 @@ discard block |
||
774 | 787 | */ |
775 | 788 | private function _setDefaults() |
776 | 789 | { |
777 | - if (!isset(self::$_template)) |
|
778 | - self::_initializeDefaults(); |
|
790 | + if (!isset(self::$_template)) { |
|
791 | + self::_initializeDefaults(); |
|
792 | + } |
|
779 | 793 | foreach (self::$_template as $k=>$v) { |
780 | - if ($k[0] != '_') |
|
781 | - $this->$k = $v; |
|
794 | + if ($k[0] != '_') { |
|
795 | + $this->$k = $v; |
|
796 | + } |
|
782 | 797 | } |
783 | 798 | return $this; |
784 | 799 | } |
@@ -808,8 +823,9 @@ discard block |
||
808 | 823 | Bootstrap::init(); |
809 | 824 | |
810 | 825 | // Setup the default template if need be |
811 | - if (!isset(self::$_template)) |
|
812 | - self::_initializeDefaults(); |
|
826 | + if (!isset(self::$_template)) { |
|
827 | + self::_initializeDefaults(); |
|
828 | + } |
|
813 | 829 | |
814 | 830 | $request = new Request(); |
815 | 831 | return $request |
@@ -829,8 +845,9 @@ discard block |
||
829 | 845 | public function _curlPrep() |
830 | 846 | { |
831 | 847 | // Check for required stuff |
832 | - if (!isset($this->uri)) |
|
833 | - throw new \Exception('Attempting to send a request before defining a URI endpoint.'); |
|
848 | + if (!isset($this->uri)) { |
|
849 | + throw new \Exception('Attempting to send a request before defining a URI endpoint.'); |
|
850 | + } |
|
834 | 851 | |
835 | 852 | if (isset($this->payload)) { |
836 | 853 | $this->serialized_payload = $this->_serializePayload($this->payload); |
@@ -853,11 +870,13 @@ discard block |
||
853 | 870 | |
854 | 871 | if ($this->hasClientSideCert()) { |
855 | 872 | |
856 | - if (!file_exists($this->client_key)) |
|
857 | - throw new \Exception('Could not read Client Key'); |
|
873 | + if (!file_exists($this->client_key)) { |
|
874 | + throw new \Exception('Could not read Client Key'); |
|
875 | + } |
|
858 | 876 | |
859 | - if (!file_exists($this->client_cert)) |
|
860 | - throw new \Exception('Could not read Client Certificate'); |
|
877 | + if (!file_exists($this->client_cert)) { |
|
878 | + throw new \Exception('Could not read Client Certificate'); |
|
879 | + } |
|
861 | 880 | |
862 | 881 | curl_setopt($ch, CURLOPT_SSLCERTTYPE, $this->client_encoding); |
863 | 882 | curl_setopt($ch, CURLOPT_SSLKEYTYPE, $this->client_encoding); |
@@ -884,7 +903,9 @@ discard block |
||
884 | 903 | // zero is safe for all curl versions |
885 | 904 | $verifyValue = $this->strict_ssl + 0; |
886 | 905 | //Support for value 1 removed in cURL 7.28.1 value 2 valid in all versions |
887 | - if ($verifyValue > 0) $verifyValue++; |
|
906 | + if ($verifyValue > 0) { |
|
907 | + $verifyValue++; |
|
908 | + } |
|
888 | 909 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $verifyValue); |
889 | 910 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
890 | 911 | |
@@ -1078,12 +1099,14 @@ discard block |
||
1078 | 1099 | */ |
1079 | 1100 | private function _serializePayload($payload) |
1080 | 1101 | { |
1081 | - if (empty($payload) || $this->serialize_payload_method === self::SERIALIZE_PAYLOAD_NEVER) |
|
1082 | - return $payload; |
|
1102 | + if (empty($payload) || $this->serialize_payload_method === self::SERIALIZE_PAYLOAD_NEVER) { |
|
1103 | + return $payload; |
|
1104 | + } |
|
1083 | 1105 | |
1084 | 1106 | // When we are in "smart" mode, don't serialize strings/scalars, assume they are already serialized |
1085 | - if ($this->serialize_payload_method === self::SERIALIZE_PAYLOAD_SMART && is_scalar($payload)) |
|
1086 | - return $payload; |
|
1107 | + if ($this->serialize_payload_method === self::SERIALIZE_PAYLOAD_SMART && is_scalar($payload)) { |
|
1108 | + return $payload; |
|
1109 | + } |
|
1087 | 1110 | |
1088 | 1111 | // Use a custom serializer if one is registered for this mime type |
1089 | 1112 | if (isset($this->payload_serializers['*']) || isset($this->payload_serializers[$this->content_type])) { |
@@ -61,7 +61,7 @@ |
||
61 | 61 | private static function _autoload($base, $classname) |
62 | 62 | { |
63 | 63 | $parts = explode(self::NS_GLUE, $classname); |
64 | - $path = $base . self::DIR_GLUE . implode(self::DIR_GLUE, $parts) . '.php'; |
|
64 | + $path = $base.self::DIR_GLUE.implode(self::DIR_GLUE, $parts).'.php'; |
|
65 | 65 | |
66 | 66 | if (file_exists($path)) { |
67 | 67 | require_once($path); |
@@ -87,8 +87,9 @@ |
||
87 | 87 | |
88 | 88 | foreach ($handlers as $mime => $handler) { |
89 | 89 | // Don't overwrite if the handler has already been registered |
90 | - if (Httpful::hasParserRegistered($mime)) |
|
91 | - continue; |
|
90 | + if (Httpful::hasParserRegistered($mime)) { |
|
91 | + continue; |
|
92 | + } |
|
92 | 93 | Httpful::register($mime, $handler); |
93 | 94 | } |
94 | 95 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require(__DIR__ . '/../bootstrap.php'); |
|
2 | +require(__DIR__.'/../bootstrap.php'); |
|
3 | 3 | |
4 | 4 | // We can override the default parser configuration options be registering |
5 | 5 | // a parser with different configuration options for a particular mime type |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | $serialized = ''; |
37 | 37 | foreach ($payload as $line) { |
38 | - $serialized .= '"' . implode('","', $line) . '"' . "\n"; |
|
38 | + $serialized .= '"'.implode('","', $line).'"'."\n"; |
|
39 | 39 | } |
40 | 40 | return $serialized; |
41 | 41 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require(__DIR__ . '/../bootstrap.php'); |
|
3 | +require(__DIR__.'/../bootstrap.php'); |
|
4 | 4 | |
5 | 5 | use \Httpful\Request; |
6 | 6 |