Skip to content

Commit

Permalink
Allow 'ContainsOp' to operate on arrays. Allow value for filter defau…
Browse files Browse the repository at this point in the history
…lt field to contain spaces.
  • Loading branch information
greg-1-anderson committed Oct 4, 2018
1 parent dbb4b8a commit 170ec2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/OperatorFactory.php
Expand Up @@ -83,7 +83,7 @@ protected function splitOnOperator($expression, $defaultField = false)
{
// If there is a default field, then any expression that is missing
// an operator will be interpreted as "default field contains value".
if (preg_match('#^[a-zA-Z0-9_.:-]+$#', $expression) && ($defaultField !== false)) {
if (preg_match('#^[a-zA-Z0-9 _.:-]+$#', $expression) && ($defaultField !== false)) {
return [$defaultField, '*=', $expression];
}
if (!preg_match('#([^!~*=]*)(!?~?\*?=)(.*)#', $expression, $matches)) {
Expand Down
3 changes: 3 additions & 0 deletions src/Operators/ContainsOp.php
Expand Up @@ -27,6 +27,9 @@ public function __construct($key, $comparitor)
public function test(Data $row)
{
$value = $row->get($this->key);
if (is_array($value)) {
return in_array($this->comparitor, $value);
}
return strpos($value, $this->comparitor) !== false;
}

Expand Down

0 comments on commit 170ec2c

Please sign in to comment.