@@ -15,34 +15,37 @@ final class QueryStringBuilder
15
15
public static function build ($ query )
16
16
{
17
17
if (!is_array ($ query )) {
18
- return static ::rawurlencode ($ query );
18
+ return self ::rawurlencode ($ query );
19
19
}
20
20
$ query = array_filter ($ query , function ($ value ) {
21
- return ( null !== $ value) ;
21
+ return null !== $ value ;
22
22
});
23
23
24
24
return implode ('& ' , array_map (function ($ value , $ key ) {
25
- return static ::encode ($ value , $ key );
25
+ return self ::encode ($ value , $ key );
26
26
}, $ query , array_keys ($ query )));
27
27
}
28
28
29
29
/**
30
- * Encode a value
31
- * @param mixed $query
30
+ * Encode a value.
31
+ *
32
+ * @param mixed $query
32
33
* @param string $prefix
33
34
*
34
35
* @return string
35
36
*/
36
37
private static function encode ($ query , $ prefix )
37
38
{
38
39
if (!is_array ($ query )) {
39
- return static ::rawurlencode ($ prefix ).'= ' .static ::rawurlencode ($ query );
40
+ return self ::rawurlencode ($ prefix ).'= ' .self ::rawurlencode ($ query );
40
41
}
41
42
42
- $ isIndexedArray = static ::isIndexedArray ($ query );
43
+ $ isIndexedArray = self ::isIndexedArray ($ query );
44
+
43
45
return implode ('& ' , array_map (function ($ value , $ key ) use ($ prefix , $ isIndexedArray ) {
44
46
$ prefix = $ isIndexedArray ? $ prefix .'[] ' : $ prefix .'[ ' .$ key .'] ' ;
45
- return static ::encode ($ value , $ prefix );
47
+
48
+ return self ::encode ($ value , $ prefix );
46
49
}, $ query , array_keys ($ query )));
47
50
}
48
51
@@ -71,10 +74,10 @@ public static function isIndexedArray(array $query)
71
74
*/
72
75
private static function rawurlencode ($ value )
73
76
{
74
- if ($ value === false ) {
77
+ if (false === $ value ) {
75
78
return '0 ' ;
76
79
}
77
80
78
- return rawurlencode ($ value );
81
+ return rawurlencode (( string ) $ value );
79
82
}
80
83
}
0 commit comments