aboutsummaryrefslogtreecommitdiff
path: root/src/Search/FTSExpr.php
diff options
context:
space:
mode:
authorLaria Carolin Chabowski <laria@laria.me>2020-02-07 09:44:59 +0100
committerLaria Carolin Chabowski <laria@laria.me>2020-02-07 09:44:59 +0100
commit2eb5a432d2229788ce2fdb09f36c6f4bebdea813 (patch)
treeab57978bdda34c82b025b897cfb6825b1fd1e654 /src/Search/FTSExpr.php
downloadmicropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.tar.gz
micropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.tar.bz2
micropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.zip
Initial commit
Diffstat (limited to 'src/Search/FTSExpr.php')
-rw-r--r--src/Search/FTSExpr.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Search/FTSExpr.php b/src/Search/FTSExpr.php
new file mode 100644
index 0000000..1123cf3
--- /dev/null
+++ b/src/Search/FTSExpr.php
@@ -0,0 +1,30 @@
+<?php
+
+
+namespace Micropoly\Search;
+
+
+class FTSExpr extends AbstractFTSExpr
+{
+ private string $term;
+
+ public function __construct(string $term)
+ {
+ $this->term = $term;
+ }
+
+ public function getTerm(): string
+ {
+ return $this->term;
+ }
+
+ protected function fts4Query(): string
+ {
+ return '"' . str_replace('"', '""', $this->term) . '"';
+ }
+
+ public function toString(): string
+ {
+ return '"' . preg_replace_callback('/(["\\\\])/', fn($s) => "\\$s", $this->term) . '"';
+ }
+} \ No newline at end of file