Skip to content

Commit 11c6119

Browse files
Update QueryStringBuilder.php
1 parent 849b604 commit 11c6119

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/Gitlab/HttpClient/Util/QueryStringBuilder.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
final class QueryStringBuilder
99
{
1010
/**
11-
* Encode a query as a query string according to RFC 3986. Indexed arrays are encoded using
12-
* empty squared brackets ([]) unlike http_build_query.
11+
* Encode a query as a query string according to RFC 3986.
12+
*
13+
* Indexed arrays are encoded using empty squared brackets ([]) unlike
14+
* `http_build_query`.
1315
*
1416
* @param mixed $query
1517
*
@@ -43,23 +45,23 @@ private static function encode($query, $prefix)
4345
return self::rawurlencode($prefix).'='.self::rawurlencode($query);
4446
}
4547

46-
$isIndexedArray = self::isIndexedArray($query);
48+
$isList = self::isList($query);
4749

48-
return implode('&', array_map(function ($value, $key) use ($prefix, $isIndexedArray) {
49-
$prefix = $isIndexedArray ? $prefix.'[]' : $prefix.'['.$key.']';
50+
return implode('&', array_map(function ($value, $key) use ($prefix, $isList) {
51+
$prefix = $isList ? $prefix.'[]' : $prefix.'['.$key.']';
5052

5153
return self::encode($value, $prefix);
5254
}, $query, array_keys($query)));
5355
}
5456

5557
/**
56-
* Tell if the given array is an indexed one (i.e. contains only sequential integer keys starting from 0).
58+
* Tell if the given array is a list.
5759
*
5860
* @param array $query
5961
*
6062
* @return bool
6163
*/
62-
public static function isIndexedArray(array $query)
64+
private static function isList(array $query)
6365
{
6466
if (0 === count($query) || !isset($query[0])) {
6567
return false;

0 commit comments

Comments
 (0)