diff options
author | Kevin Decherf <kevin@kdecherf.com> | 2020-04-26 15:39:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-26 15:39:57 +0200 |
commit | 0e8a0f77d0b643a884e6687bd9c463267852a970 (patch) | |
tree | 88c6761b4215637bba34b263015e87750c92a187 /src/Wallabag/CoreBundle/Operator | |
parent | 8a8a78a64c116caf81aaa4339906298bdc0e32e0 (diff) | |
parent | 71f7e58fbd84e1d15c7a405a3c5872adb937dc37 (diff) | |
download | wallabag-0e8a0f77d0b643a884e6687bd9c463267852a970.tar.gz wallabag-0e8a0f77d0b643a884e6687bd9c463267852a970.tar.zst wallabag-0e8a0f77d0b643a884e6687bd9c463267852a970.zip |
Merge pull request #4026 from wallabag/3760-ignorelist-db
Move Ignore Origin rules to database
Diffstat (limited to 'src/Wallabag/CoreBundle/Operator')
-rw-r--r-- | src/Wallabag/CoreBundle/Operator/PHP/PatternMatches.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Operator/PHP/PatternMatches.php b/src/Wallabag/CoreBundle/Operator/PHP/PatternMatches.php new file mode 100644 index 00000000..532e2bb3 --- /dev/null +++ b/src/Wallabag/CoreBundle/Operator/PHP/PatternMatches.php | |||
@@ -0,0 +1,23 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Operator\PHP; | ||
4 | |||
5 | /** | ||
6 | * Provides a "~" operator used for ignore origin rules. | ||
7 | * | ||
8 | * It asserts that a subject matches a given regexp pattern, in a | ||
9 | * case-insensitive way. | ||
10 | * | ||
11 | * This operator will be used to compile ignore origin rules in PHP, usable | ||
12 | * directly on Entry objects for instance. | ||
13 | * It's registered in RulerZ using a service (wallabag.operator.array.pattern_matches); | ||
14 | */ | ||
15 | class PatternMatches | ||
16 | { | ||
17 | public function __invoke($subject, $pattern) | ||
18 | { | ||
19 | $count = preg_match("`$pattern`i", $subject); | ||
20 | |||
21 | return \is_int($count) && $count > 0; | ||
22 | } | ||
23 | } | ||