Issues (590)

src/Query/Expression/FullTextMatch.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Bdf\Prime\Query\Expression;
4
5
use Bdf\Prime\Query\CompilableClause;
6
use Bdf\Prime\Query\Compiler\CompilerInterface;
7
use Bdf\Prime\Query\Compiler\SqlCompiler;
8
9
/**
10
 * FullTextMatch
11
 *
12
 * The fulltext search expression
13
 *
14
 * @package Bdf\Prime\Query\Expression
15
 *
16
 * @template Q as \Bdf\Prime\Query\CompilableClause&\Bdf\Prime\Query\SqlQueryInterface
17
 * @implements ExpressionInterface<Q, \Bdf\Prime\Query\Compiler\SqlCompiler>
18
 */
19
class FullTextMatch implements ExpressionInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $search;
25
26
    /**
27
     * @var mixed
28
     */
29
    protected $value;
30
31
    /**
32
     * @var bool
33
     */
34
    protected $booleanMode;
35
36
    /**
37
     * Constructor
38
     *
39
     * @param string  $search
40
     * @param array   $value
41
     * @param boolean $booleanMode
42
     */
43 2
    public function __construct($search, $value, $booleanMode = false)
44
    {
45 2
        $this->search = $search;
46 2
        $this->value = $value;
47 2
        $this->booleanMode = $booleanMode;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     *
53
     * @param Q $query
0 ignored issues
show
The type Bdf\Prime\Query\Expression\Q was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
54
     * @param SqlCompiler $compiler
55
     */
56 2
    public function build(CompilableClause $query, object $compiler)
57
    {
58 2
        $sql = 'MATCH('.$compiler->quoteIdentifier($query, $query->preprocessor()->field($this->search)).' AGAINST('.$compiler->quote($this->value).')';
59
60 2
        if ($this->booleanMode) {
61 1
            $sql .= ' IN BOOLEAN MODE)';
62
        } else {
63 1
            $sql .= ')';
64
        }
65
66 2
        return $sql;
67
    }
68
}
69