aboutsummaryrefslogtreecommitdiff
path: root/src/Search/NotOp.php
blob: 35fcf1e34ce98d6562a3a655b39520ea88c40b61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php


namespace Micropoly\Search;


class NotOp implements SearchExpr
{
    private SearchExpr $expr;

    public function __construct(SearchExpr $expr)
    {
        $this->expr = $expr;
    }

    public function toString(): string
    {
        return "not ({$this->expr->toString()})";
    }

    public function toSQL(string $bindPrefix, bool $singleFTS): SQLSearchExpr
    {
        $sqlex = $this->expr->toSQL($bindPrefix, $singleFTS);
        $sqlex->sql = "(NOT ({$sqlex->sql}))";
        return $sqlex;
    }

    public function countFTSQueries(): int
    {
        return $this->expr->countFTSQueries();
    }
}