23 const BLANK =
"_guzzle_blank_";
38 private static $defaultAggregator =
null;
54 $foundDuplicates = $foundPhpStyle =
false;
56 foreach (explode(
'&', $query) as $kvp) {
57 $parts = explode(
'=', $kvp, 2);
58 $key = rawurldecode($parts[0]);
59 if ($paramIsPhpStyleArray = substr($key, -2) ==
'[]') {
60 $foundPhpStyle =
true;
61 $key = substr($key, 0, -2);
63 if (isset($parts[1])) {
64 $value = rawurldecode(str_replace(
'+',
'%20', $parts[1]));
65 if (isset($q[$key])) {
66 $q->add($key, $value);
67 $foundDuplicates =
true;
68 } elseif ($paramIsPhpStyleArray) {
69 $q[$key] = array($value);
80 if ($foundDuplicates && !$foundPhpStyle) {
81 $q->setAggregator(
new DuplicateAggregator());
100 foreach ($this->
prepareData($this->data) as $name => $value) {
101 $queryList[] = $this->convertKvp($name, $value);
104 return implode($this->fieldSeparator, $queryList);
164 if (!self::$defaultAggregator) {
184 $this->
urlEncode = ($encode ===
true) ? self::RFC_3986 : $encode;
198 $this->fieldSeparator = $separator;
212 $this->valueSeparator = $separator;
236 if ($this->
urlEncode == self::RFC_3986) {
237 return rawurlencode($value);
238 } elseif ($this->
urlEncode == self::FORM_URLENCODED) {
239 return urlencode($value);
241 return (
string) $value;
255 if (!$this->aggregator) {
260 foreach (
$data as $key => $value) {
261 if ($value ===
false || $value ===
null) {
264 } elseif (is_array($value)) {
265 $temp = array_merge($temp, $this->aggregator->aggregate($key, $value, $this));
282 private function convertKvp($name, $value)
284 if ($value === self::BLANK || $value ===
null || $value ===
false) {
286 } elseif (!is_array($value)) {
287 return $name . $this->valueSeparator . $value;
291 foreach ($value as $v) {
295 return rtrim($result, $this->fieldSeparator);