Query::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace BestServedCold\LaravelZendSearch\Lucene;
4
5
use ZendSearch\Lucene\Search\Query\Boolean as LuceneBoolean;
6
use ZendSearch\Lucene\Search\Query\AbstractQuery;
7
use ZendSearch\Lucene\Search\Query\Boolean;
8
9
/**
10
 * Class Query
11
 *
12
 * @package BestServedCold\LaravelZendSearch\Lucene
13
 */
14
class Query
15
{
16
    /**
17
     * @var bool
18
     */
19
    private $sign = true;
20
21
    /**
22
     * @var LuceneBoolean
23
     */
24
    private $boolean;
25
26
    /**
27
     * Query constructor.
28
     *
29
     * @param LuceneBoolean $boolean
30
     */
31 36
    public function __construct(LuceneBoolean $boolean)
32
    {
33 36
        $this->boolean = $boolean;
34 36
    }
35
36
    /**
37
     * Add
38
     *
39
     * @param  AbstractQuery $query
40
     * @return $this
41
     */
42 6
    public function add(AbstractQuery $query)
43
    {
44 6
        $this->boolean->addSubquery($query, $this->sign);
45 6
        $this->sign = true;
46 6
        return $this;
47
    }
48
49
    /**
50
     * Required
51
     *
52
     * @return $this
53
     */
54 1
    public function required()
55
    {
56 1
        $this->sign = true;
57 1
        return $this;
58
    }
59
60
    /**
61
     * Optional
62
     *
63
     * @return $this
64
     */
65 1
    public function optional()
66
    {
67 1
        $this->sign = null;
68 1
        return $this;
69
    }
70
71
    /**
72
     * Prohibited
73
     *
74
     * @return $this
75
     */
76 1
    public function prohibited()
77
    {
78 1
        $this->sign = false;
79 1
        return $this;
80
    }
81
82
    /**
83
     * Get Boolean
84
     *
85
     * @return LuceneBoolean
86
     */
87 3
    public function getBoolean()
88
    {
89 3
        return $this->boolean;
90
    }
91
92
    /**
93
     * Get Sign
94
     *
95
     * @return bool
96
     */
97 3
    public function getSign()
98
    {
99 3
        return $this->sign;
100
    }
101
}
102