Skip to content

Commit dce0aef

Browse files
authored
Merge pull request php-curl-class#359 from zachborboa/master
Clean up
2 parents 653bd6d + d2d4fe3 commit dce0aef

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

src/Curl/Curl.php

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,14 @@ public function beforeSend($callback)
136136
public function buildPostData($data)
137137
{
138138
if (is_array($data)) {
139-
if (self::is_array_multidim($data)) {
140-
if (isset($this->headers['Content-Type']) &&
141-
preg_match($this->jsonPattern, $this->headers['Content-Type'])) {
142-
$json_str = json_encode($data);
143-
if (!($json_str === false)) {
144-
$data = $json_str;
145-
}
146-
} else {
147-
$data = self::http_build_multi_query($data);
139+
if (isset($this->headers['Content-Type']) &&
140+
preg_match($this->jsonPattern, $this->headers['Content-Type'])) {
141+
$json_str = json_encode($data);
142+
if (!($json_str === false)) {
143+
$data = $json_str;
148144
}
145+
} else if (self::is_array_multidim($data)) {
146+
$data = self::http_build_multi_query($data);
149147
} else {
150148
$binary_data = false;
151149
foreach ($data as $key => $value) {
@@ -166,15 +164,7 @@ public function buildPostData($data)
166164
}
167165

168166
if (!$binary_data) {
169-
if (isset($this->headers['Content-Type']) &&
170-
preg_match($this->jsonPattern, $this->headers['Content-Type'])) {
171-
$json_str = json_encode($data);
172-
if (!($json_str === false)) {
173-
$data = $json_str;
174-
}
175-
} else {
176-
$data = http_build_query($data, '', '&');
177-
}
167+
$data = http_build_query($data, '', '&');
178168
}
179169
}
180170
}
@@ -988,7 +978,7 @@ public function unsetHeader($key)
988978
* @param bool $on
989979
* @param resource $output
990980
*/
991-
public function verbose($on = true, $output=STDERR)
981+
public function verbose($on = true, $output = STDERR)
992982
{
993983
// Turn off CURLINFO_HEADER_OUT for verbose to work. This has the side
994984
// effect of causing Curl::requestHeaders to be empty.

0 commit comments

Comments
 (0)