Add matches operator

This commit is contained in:
Kévin Gomez
2015-11-13 14:37:58 +01:00
parent 5c514b0be3
commit a6e27f7466
6 changed files with 47 additions and 11 deletions

View File

@ -0,0 +1,15 @@
<?php
namespace Wallabag\CoreBundle\Operator\Doctrine;
class Matches
{
public function __invoke($subject, $pattern)
{
if ($pattern[0] === "'") {
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
}
return sprintf('UPPER(%s) LIKE UPPER(%s)', $subject, $pattern);
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace Wallabag\CoreBundle\Operator\PHP;
class Matches
{
public function __invoke($subject, $pattern)
{
return stripos($subject, $pattern) !== false;
}
}