Skip to content

Commit e809c33

Browse files
committed
Added: support for matching against array of keys for array_key_value matching type.
1 parent 2b9f5e0 commit e809c33

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/Processor.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -390,16 +390,24 @@ public function matchParameterValue($match, $value)
390390

391391
// If a specific parameter key matches a sub-match condition.
392392
if ($matchType == 'array_key_value' && isset($match['key'], $match['match'])) {
393-
$values = $this->request->getParameterValues($match['key'], $value);
394-
if (!is_array($values)) {
395-
return false;
396-
}
397393

398-
foreach ($values as $value) {
399-
if ($this->matchParameterValue($match['match'], $value)) {
400-
return true;
394+
// To support arrays for the key matching type value.
395+
$keys = is_array($match['key']) ? $match['key'] : [$match['key']];
396+
397+
// Iterate through all keys.
398+
foreach ($keys as $key) {
399+
$values = $this->request->getParameterValues($key, $value);
400+
if (!is_array($values)) {
401+
continue;
402+
}
403+
404+
foreach ($values as $val) {
405+
if ($this->matchParameterValue($match['match'], $val)) {
406+
return true;
407+
}
401408
}
402409
}
410+
403411
return false;
404412
}
405413

src/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct($options, ExtensionInterface $extension)
4242
public function getParameterValues($parameter, $data = [])
4343
{
4444
// For when a rule contains sub-rules.
45-
if (empty($parameter) || ctype_digit($parameter)) {
45+
if (empty($parameter) || ctype_digit($parameter) || !is_array($data)) {
4646
return null;
4747
}
4848

0 commit comments

Comments
 (0)