Completed
Branch master (3a11a5)
by Adam
06:08 queued 02:35
created

Query::__construct()   A

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