Passed
Push — sheepy/introspection ( 69e16c...c6c7ca )
by Marco
05:28
created

BaseQuery   A

Complexity

Total Complexity 25

Size/Duplication

Total Lines 312
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 25
eloc 54
c 1
b 0
f 0
dl 0
loc 312
rs 10
ccs 64
cts 64
cp 1

25 Methods

Rating   Name   Duplication   Size   Complexity  
A setFacetsMinCount() 0 5 1
A getFacetsMinCount() 0 3 1
A getSort() 0 3 1
A getTerms() 0 3 1
A setTerms() 0 5 1
A setSort() 0 5 1
A getFields() 0 3 1
A getStart() 0 3 1
A getExclude() 0 3 1
A setExclude() 0 5 1
A getRows() 0 3 1
A addHighlight() 0 5 1
A setFields() 0 5 1
A getHighlight() 0 3 1
A setStart() 0 5 1
A getFilter() 0 3 1
A setFilter() 0 5 1
A shouldFollowSpellcheck() 0 3 1
A hasSpellcheck() 0 3 1
A setFollowSpellcheck() 0 5 1
A getFacetFilter() 0 3 1
A setFacetFilter() 0 5 1
A setHighlight() 0 5 1
A setSpellcheck() 0 5 1
A setRows() 0 5 1
1
<?php
2
3
4
namespace Firesphere\SolrSearch\Queries;
5
6
use Firesphere\SolrSearch\Traits\BaseQueryTrait;
7
use Firesphere\SolrSearch\Traits\GetterSetterTrait;
8
9
/**
10
 * Class BaseQuery
11
 * @package Firesphere\SolrSearch\Queries
12
 */
13
class BaseQuery
14
{
15
    use GetterSetterTrait;
16
    use BaseQueryTrait;
17
    /**
18
     * @var array
19
     */
20
    protected $history = [];
21
    /**
22
     * Key-value pairs of fields and what to filter against
23
     *
24
     * @var array
25
     */
26
    protected $filter = [];
27
    /**
28
     * @var array
29
     */
30
    protected $exclude = [];
31
    /**
32
     * Key => value pairs of facets to apply
33
     * [
34
     *     'FacetTitle' => [1, 2, 3]
35
     * ]
36
     * @var array
37
     */
38
    protected $facetFilter = [];
39
    /**
40
     * @var int
41
     */
42
    protected $start = 0;
43
44
    /**
45
     * @var int
46
     */
47
    protected $rows = 10;
48
49
    /**
50
     * Always get the ID. If you don't, you need to implement your own solution
51
     * @var array
52
     */
53
    protected $fields = [];
54
55
    /**
56
     * @var array
57
     */
58
    protected $sort = [];
59
60
    /**
61
     * Enable spellchecking?
62
     * @var bool
63
     */
64
    protected $spellcheck = true;
65
66
    /**
67
     * Follow spellchecking if there are no results
68
     * @var bool
69
     */
70
    protected $followSpellcheck = false;
71
72
    /**
73
     * @var int
74
     */
75
    protected $facetsMinCount = 0;
76
77 5
    /**
78
     * @var array
79 5
     */
80
    protected $terms = [];
81
82
    /**
83
     * @var array
84
     */
85
    protected $highlight = [];
86 1
87
    /**
88 1
     * @return int
89
     */
90 1
    public function getStart(): int
91
    {
92
        return $this->start;
93
    }
94
95
    /**
96 5
     * @param int $start
97
     * @return $this
98 5
     */
99
    public function setStart($start): self
100
    {
101
        $this->start = $start;
102
103
        return $this;
104
    }
105 1
106
    /**
107 1
     * @return int
108
     */
109 1
    public function getRows(): int
110
    {
111
        return $this->rows;
112
    }
113
114
    /**
115 5
     * @param int $rows
116
     * @return $this
117 5
     */
118
    public function setRows($rows): self
119
    {
120
        $this->rows = $rows;
121
122
        return $this;
123
    }
124
125 1
    /**
126
     * @return array
127 1
     */
128
    public function getFields(): array
129 1
    {
130
        return $this->fields;
131
    }
132
133
    /**
134
     * Set fields to be returned
135
     * @param array $fields
136
     * @return $this
137 2
     */
138
    public function setFields($fields): self
139 2
    {
140
        $this->fields = $fields;
141 2
142
        return $this;
143
    }
144
145
    /**
146
     * @return array
147 1
     */
148
    public function getSort(): array
149 1
    {
150
        return $this->sort;
151
    }
152
153
    /**
154
     * @param array $sort
155
     * @return $this
156 1
     */
157
    public function setSort($sort): self
158 1
    {
159
        $this->sort = $sort;
160 1
161
        return $this;
162
    }
163
164
    /**
165
     * @return int
166 5
     */
167
    public function getFacetsMinCount(): int
168 5
    {
169
        return $this->facetsMinCount;
170
    }
171
172
    /**
173
     * @param mixed $facetsMinCount
174
     * @return $this
175 1
     */
176
    public function setFacetsMinCount($facetsMinCount): self
177 1
    {
178
        $this->facetsMinCount = $facetsMinCount;
179 1
180
        return $this;
181
    }
182
183
    /**
184
     * @return array
185 5
     */
186
    public function getTerms(): array
187 5
    {
188
        return $this->terms;
189
    }
190
191
    /**
192
     * @param array $terms
193
     * @return $this
194 1
     */
195
    public function setTerms($terms): self
196 1
    {
197
        $this->terms = $terms;
198 1
199
        return $this;
200
    }
201
202
    /**
203
     * @return array
204
     */
205
    public function getFilter(): array
206
    {
207
        return $this->filter;
208
    }
209
210
    /**
211
     * @param array $filter
212
     * @return $this
213
     */
214
    public function setFilter($filter): self
215
    {
216
        $this->filter = $filter;
217
218 4
        return $this;
219
    }
220 4
221 4
    /**
222 4
     * @return array
223 4
     */
224 4
    public function getExclude(): array
225
    {
226
        return $this->exclude;
227 4
    }
228
229
    /**
230
     * @param array $exclude
231
     * @return $this
232
     */
233
    public function setExclude($exclude): self
234
    {
235 2
        $this->exclude = $exclude;
236
237 2
        return $this;
238
    }
239 2
240
    /**
241
     * @param $field
242
     * @return $this
243
     */
244
    public function addHighlight($field): self
245 5
    {
246
        $this->highlight[] = $field;
247 5
248
        return $this;
249
    }
250
251
    /**
252
     * @return array
253
     */
254 1
    public function getHighlight(): array
255
    {
256 1
        return $this->highlight;
257
    }
258 1
259
    /**
260
     * @param array $highlight
261
     * @return $this
262
     */
263
    public function setHighlight($highlight): self
264
    {
265
        $this->highlight = $highlight;
266 2
267
        return $this;
268 2
    }
269
270 2
    /**
271
     * @return bool
272
     */
273
    public function hasSpellcheck(): bool
274
    {
275
        return $this->spellcheck;
276 5
    }
277
278 5
    /**
279
     * @param bool $spellcheck
280
     * @return self
281
     */
282
    public function setSpellcheck(bool $spellcheck): self
283
    {
284
        $this->spellcheck = $spellcheck;
285 1
286
        return $this;
287 1
    }
288
289 1
    /**
290
     * @param bool $followSpellcheck
291
     * @return BaseQuery
292
     */
293
    public function setFollowSpellcheck(bool $followSpellcheck): BaseQuery
294
    {
295
        $this->followSpellcheck = $followSpellcheck;
296 1
297
        return $this;
298 1
    }
299
300 1
    /**
301
     * @return bool
302
     */
303
    public function shouldFollowSpellcheck(): bool
304
    {
305
        return $this->followSpellcheck;
306 5
    }
307
308 5
    /**
309
     * @return array
310
     */
311
    public function getFacetFilter(): array
312
    {
313
        return $this->facetFilter;
314
    }
315 1
316
    /**
317 1
     * @param array $facetFilter
318
     * @return BaseQuery
319 1
     */
320
    public function setFacetFilter(array $facetFilter): self
321
    {
322
        $this->facetFilter = $facetFilter;
323
324
        return $this;
325 4
    }
326
}
327