aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Operator
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-05-03 11:53:01 +0200
committerGitHub <noreply@github.com>2017-05-03 11:53:01 +0200
commit9c09c253fea8d618f1be110677a1a9c76e3afdcd (patch)
tree37c00c043d2ead9e49f93fa3e1544d3d4aceffda /src/Wallabag/CoreBundle/Operator
parentdfa0822f197991f96d427112c23abd460198817d (diff)
parenta162b1a99b0bd4ccebbd129170d043a621bed710 (diff)
downloadwallabag-9c09c253fea8d618f1be110677a1a9c76e3afdcd.tar.gz
wallabag-9c09c253fea8d618f1be110677a1a9c76e3afdcd.tar.zst
wallabag-9c09c253fea8d618f1be110677a1a9c76e3afdcd.zip
Merge pull request #3047 from wallabag/add-notmatches-operator
Added notmatches operator for tagging rule
Diffstat (limited to 'src/Wallabag/CoreBundle/Operator')
-rw-r--r--src/Wallabag/CoreBundle/Operator/Doctrine/NotMatches.php25
-rw-r--r--src/Wallabag/CoreBundle/Operator/PHP/NotMatches.php21
2 files changed, 46 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Operator/Doctrine/NotMatches.php b/src/Wallabag/CoreBundle/Operator/Doctrine/NotMatches.php
new file mode 100644
index 00000000..b7f9da57
--- /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/NotMatches.php b/src/Wallabag/CoreBundle/Operator/PHP/NotMatches.php
new file mode 100644
index 00000000..68b2676f
--- /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 stripos($subject, $pattern) === false;
20 }
21}