Skip to content

Commit 5cd8723

Browse files
committed
MAGETWO-30299: [Code Quality] Reduce Complexity of Web API Classes
- CR changes - Reverted changes made for \Magento\Framework\Webapi\Rest\Response\FieldsFilter
1 parent 225623f commit 5cd8723

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/internal/Magento/Framework/Webapi/Rest/Response/FieldsFilter.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ public function filter($response)
4040
if (!is_string($filter)) {
4141
return [];
4242
}
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);
4744
if (is_null($filterArray)) {
4845
return [];
4946
}
@@ -55,7 +52,6 @@ public function filter($response)
5552
* Parse filter string into associative array. Field names are returned as keys with values for scalar fields as 1.
5653
*
5754
* @param string $filterString
58-
* @param int $length
5955
* <pre>
6056
* ex. customer[id,email],addresses[city,postcode,region[region_code,region]]
6157
* </pre>
@@ -83,8 +79,14 @@ public function filter($response)
8379
*
8480
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
8581
*/
86-
protected function parse($filterString, $length)
82+
protected function parse($filterString)
8783
{
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+
8890
$start = null;
8991
$current = [];
9092
$stack = [];

0 commit comments

Comments
 (0)