Skip to content

Commit 42c7a5e

Browse files
committed
replaced my own parseQuery function with php's parse_str
1 parent 77f67a3 commit 42c7a5e

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

src/Http/Request.php

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -114,33 +114,10 @@ public function getMethod(){
114114
return $this->method;
115115
}
116116

117-
// https://github.com/guzzle/psr7/blob/master/src/functions.php
117+
// this was no longer working --- https://github.com/guzzle/psr7/blob/master/src/functions.php
118118
public static function parseQuery($query){
119-
120119
$result = array();
121-
122-
foreach(explode('&', $query) as $kvp){
123-
$parts = explode('=', $kvp);
124-
$key = rawurldecode($parts[0]);
125-
if(substr($key, -2) == '[]'){
126-
$key = substr($key, 0, -2);
127-
}
128-
129-
// keys with NULL will be ignored in http_build_query - that's why it has to be ''
130-
$value = isset($parts[1]) ? rawurldecode($parts[1]) : '';
131-
132-
// brand new key=value
133-
if(!isset($result[$key])){
134-
$result[$key] = $value;
135-
} else {
136-
// key already exists in some form...
137-
if(!is_array($result[$key])){
138-
$result[$key] = array($result[$key]);
139-
}
140-
141-
$result[$key][] = $value;
142-
}
143-
}
120+
parse_str($query, $result);
144121

145122
return $result;
146123
}

0 commit comments

Comments
 (0)