aboutsummaryrefslogtreecommitdiff
path: root/src/Search/FTSExpr.php
diff options
context:
space:
mode:
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