]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php
CS
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Operator / Doctrine / Matches.php
CommitLineData
a6e27f74
KG
1<?php
2
3namespace Wallabag\CoreBundle\Operator\Doctrine;
4
f27aca26
KG
5/**
6 * Provides a "matches" operator used for tagging rules.
7 *
8 * It asserts that a given pattern is 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.matches);
14 */
a6e27f74
KG
15class Matches
16{
17 public function __invoke($subject, $pattern)
18 {
3ef055ce 19 if ("'" === $pattern[0]) {
a6e27f74
KG
20 $pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
21 }
22
23 return sprintf('UPPER(%s) LIKE UPPER(%s)', $subject, $pattern);
24 }
25}