aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Operator
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Operator')
-rw-r--r--src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php2
-rw-r--r--src/Wallabag/CoreBundle/Operator/Doctrine/NotMatches.php25
-rw-r--r--src/Wallabag/CoreBundle/Operator/PHP/Matches.php2
-rw-r--r--src/Wallabag/CoreBundle/Operator/PHP/NotMatches.php21
4 files changed, 48 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php b/src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php
index e6bb03b1..e1610161 100644
--- a/src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php
+++ b/src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php
@@ -16,7 +16,7 @@ class Matches
16{ 16{
17 public function __invoke($subject, $pattern) 17 public function __invoke($subject, $pattern)
18 { 18 {
19 if ($pattern[0] === "'") { 19 if ("'" === $pattern[0]) {
20 $pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1)); 20 $pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
21 } 21 }
22 22
diff --git a/src/Wallabag/CoreBundle/Operator/Doctrine/NotMatches.php b/src/Wallabag/CoreBundle/Operator/Doctrine/NotMatches.php
new file mode 100644
index 00000000..8e50f8d6
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Operator/Doctrine/NotMatches.php
@@ -0,0 +1,25 @@
1<?php
2
3namespace Wallabag\CoreBundle\Operator\Doctrine;
4
5/**
6 * Provides a "notmatches" operator used for tagging rules.
7 *
8 * It asserts that a given pattern is not contained in a subject, in a
9 * case-insensitive way.
10 *
11 * This operator will be used to compile tagging rules in DQL, usable
12 * by Doctrine ORM.
13 * It's registered in RulerZ using a service (wallabag.operator.doctrine.notmatches);
14 */
15class NotMatches
16{
17 public function __invoke($subject, $pattern)
18 {
19 if ("'" === $pattern[0]) {
20 $pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
21 }
22
23 return sprintf('UPPER(%s) NOT LIKE UPPER(%s)', $subject, $pattern);
24 }
25}
diff --git a/src/Wallabag/CoreBundle/Operator/PHP/Matches.php b/src/Wallabag/CoreBundle/Operator/PHP/Matches.php
index 987ed2a5..bc0c3f8f 100644
--- a/src/Wallabag/CoreBundle/Operator/PHP/Matches.php
+++ b/src/Wallabag/CoreBundle/Operator/PHP/Matches.php
@@ -16,6 +16,6 @@ class Matches
16{ 16{
17 public function __invoke($subject, $pattern) 17 public function __invoke($subject, $pattern)
18 { 18 {
19 return stripos($subject, $pattern) !== false; 19 return false !== stripos($subject, $pattern);
20 } 20 }
21} 21}
diff --git a/src/Wallabag/CoreBundle/Operator/PHP/NotMatches.php b/src/Wallabag/CoreBundle/Operator/PHP/NotMatches.php
new file mode 100644
index 00000000..bd4d887a
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Operator/PHP/NotMatches.php
@@ -0,0 +1,21 @@
1<?php
2
3namespace Wallabag\CoreBundle\Operator\PHP;
4
5/**
6 * Provides a "notmatches" operator used for tagging rules.
7 *
8 * It asserts that a given pattern is not contained in a subject, in a
9 * case-insensitive way.
10 *
11 * This operator will be used to compile tagging rules in PHP, usable
12 * directly on Entry objects for instance.
13 * It's registered in RulerZ using a service (wallabag.operator.array.notmatches);
14 */
15class NotMatches
16{
17 public function __invoke($subject, $pattern)
18 {
19 return false === stripos($subject, $pattern);
20 }
21}