@@ -40,10 +40,7 @@ public function filter($response)
40
40
if (!is_string ($ filter )) {
41
41
return [];
42
42
}
43
- $ length = strlen ($ filter );
44
- //Permissible characters in filter string: letter, number, underscore, square brackets and comma
45
- //Set $filterArray to be null if $filter is empty or has invalid characters
46
- $ filterArray = ($ length == 0 || preg_match ('/[^\w\[\],]+/ ' , $ filter )) ? null : $ this ->parse ($ filter , $ length );
43
+ $ filterArray = $ this ->parse ($ filter );
47
44
if (is_null ($ filterArray )) {
48
45
return [];
49
46
}
@@ -55,7 +52,6 @@ public function filter($response)
55
52
* Parse filter string into associative array. Field names are returned as keys with values for scalar fields as 1.
56
53
*
57
54
* @param string $filterString
58
- * @param int $length
59
55
* <pre>
60
56
* ex. customer[id,email],addresses[city,postcode,region[region_code,region]]
61
57
* </pre>
@@ -83,8 +79,14 @@ public function filter($response)
83
79
*
84
80
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
85
81
*/
86
- protected function parse ($ filterString, $ length )
82
+ protected function parse ($ filterString )
87
83
{
84
+ $ length = strlen ($ filterString );
85
+ //Permissible characters in filter string: letter, number, underscore, square brackets and comma
86
+ if ($ length == 0 || preg_match ('/[^\w\[\],]+/ ' , $ filterString )) {
87
+ return null ;
88
+ }
89
+
88
90
$ start = null ;
89
91
$ current = [];
90
92
$ stack = [];
0 commit comments