SearchResultSet::getUsedQuery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet;
4
5
/***************************************************************
6
 *  Copyright notice
7
 *
8
 *  (c) 2015-2016 Timo Schmidt <[email protected]>
9
 *  All rights reserved
10
 *
11
 *  This script is part of the TYPO3 project. The TYPO3 project is
12
 *  free software; you can redistribute it and/or modify
13
 *  it under the terms of the GNU General Public License as published by
14
 *  the Free Software Foundation; either version 3 of the License, or
15
 *  (at your option) any later version.
16
 *
17
 *  The GNU General Public License can be found at
18
 *  http://www.gnu.org/copyleft/gpl.html.
19
 *
20
 *  This script is distributed in the hope that it will be useful,
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 *  GNU General Public License for more details.
24
 *
25
 *  This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27
28
use ApacheSolrForTypo3\Solr\Domain\Search\Query\Query;
29
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\AbstractFacet;
30
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\FacetCollection;
31
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\SearchResult;
32
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\SearchResultCollection;
33
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Sorting\Sorting;
34
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Sorting\SortingCollection;
35
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Spellchecking\Suggestion;
36
use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequest;
37
use ApacheSolrForTypo3\Solr\Search;
38
use ApacheSolrForTypo3\Solr\System\Solr\ResponseAdapter;
39
40
/**
41
 * The SearchResultSet is used to provided access to the \Apache_Solr_Response and
42
 * other relevant information, like the used Query and Request objects.
43
 *
44
 * @author Timo Schmidt <[email protected]>
45
 */
46
class SearchResultSet
47
{
48
49
    /**
50
     * @var Query
51
     */
52
    protected $usedQuery = null;
53
54
    /**
55
     * @var SearchRequest
56
     */
57
    protected $usedSearchRequest = null;
58
59
    /**
60
     * @var Search
61
     */
62
    protected $usedSearch;
63
64
    /**
65
     * @var ResponseAdapter
66
     */
67
    protected $response = null;
68
69
    /**
70
     * @var int
71
     */
72
    protected $usedPage = 0;
73
74
    /**
75
     * @var int
76
     */
77
    protected $usedResultsPerPage = 0;
78
79
    /**
80
     * @var array
81
     */
82
    protected $usedAdditionalFilters = [];
83
84
    /**
85
     * @var SearchResultCollection
86
     */
87
    protected $searchResults = null;
88
89
    /**
90
     * @var int
91
     */
92
    protected $allResultCount = 0;
93
94
    /**
95
     * @var float
96
     */
97
    protected $maximumScore = 0.0;
98
99
    /**
100
     * @var Suggestion[]
101
     */
102
    protected $spellCheckingSuggestions = [];
103
104
    /**
105
     * @var FacetCollection
106
     */
107
    protected $facets = null;
108
109
    /**
110
     * @var SortingCollection
111
     */
112
    protected $sortings = null;
113
114
    /**
115
     * @var bool
116
     */
117
    protected $isAutoCorrected = false;
118
119
    /**
120
     * @var string
121
     */
122
    protected $initialQueryString = '';
123
124
    /**
125
     * @var string
126
     */
127
    protected $correctedQueryString = '';
128
129
    /**
130 94
     * @var bool
131
     */
132 94
    protected $hasSearched = false;
133 94
134 94
    /**
135 94
     * @return \ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet
136
     */
137
    public function __construct()
138
    {
139
        $this->facets = new FacetCollection();
140 68
        $this->sortings = new SortingCollection();
141
        $this->searchResults = new SearchResultCollection();
142 68
    }
143 68
144
    /**
145
     * @param int $allResultCount
146
     */
147
    public function setAllResultCount($allResultCount)
148 33
    {
149
        $this->allResultCount = $allResultCount;
150 33
    }
151
152
    /**
153
     * @return int
154
     */
155
    public function getAllResultCount()
156 5
    {
157
        return $this->allResultCount;
158 5
    }
159 5
160
    /**
161
     * @param Suggestion $suggestion
162
     */
163
    public function addSpellCheckingSuggestion(Suggestion $suggestion)
164 34
    {
165
        $this->spellCheckingSuggestions[$suggestion->getSuggestion()] = $suggestion;
166 34
    }
167
168
    /**
169
     * @return bool
170
     */
171
    public function getHasSpellCheckingSuggestions()
172
    {
173
        return count($this->spellCheckingSuggestions) > 0;
174
    }
175
176
    /**
177
     * @param \ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Spellchecking\Suggestion[] $spellCheckingSuggestions
178
     */
179
    public function setSpellCheckingSuggestions($spellCheckingSuggestions)
180 4
    {
181
        $this->spellCheckingSuggestions = $spellCheckingSuggestions;
182 4
    }
183
184
    /**
185
     * @return \ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Spellchecking\Suggestion[]
186
     */
187
    public function getSpellCheckingSuggestions()
188 68
    {
189
        return $this->spellCheckingSuggestions;
190 68
    }
191
192
    /**
193
     * @return FacetCollection
194
     */
195
    public function getFacets()
196 62
    {
197
        return $this->facets;
198 62
    }
199 62
200
    /**
201
     * @param AbstractFacet $facet
202
     */
203
    public function addFacet(AbstractFacet $facet)
204 33
    {
205
        $this->facets->addFacet($facet);
206 33
    }
207 33
208
    /**
209
     * @return float
210
     */
211
    public function getMaximumScore()
212 32
    {
213
        return $this->maximumScore;
214 32
    }
215
216
    /**
217
     * @param float $maximumScore
218
     */
219
    public function setMaximumScore($maximumScore)
220 84
    {
221
        $this->maximumScore = $maximumScore;
222 84
    }
223 84
224
    /**
225
     * @param Sorting $sorting
226
     */
227
    public function addSorting(Sorting $sorting)
228 84
    {
229
        $this->sortings->addSorting($sorting);
230 84
    }
231
232
    /**
233
     * @return SortingCollection
234
     */
235
    public function getSortings()
236 42
    {
237
        return $this->sortings;
238 42
    }
239 42
240
    /**
241
     * @param ResponseAdapter $response
242
     */
243
    public function setResponse($response)
244
    {
245
        $this->response = $response;
246
    }
247
248
    /**
249
     * @return ResponseAdapter
250
     */
251
    public function getResponse()
252 43
    {
253
        return $this->response;
254 43
    }
255 43
256
    /**
257
     * @param array $usedAdditionalFilters
258
     */
259
    public function setUsedAdditionalFilters($usedAdditionalFilters)
260
    {
261
        $this->usedAdditionalFilters = $usedAdditionalFilters;
262 35
    }
263
264 35
    /**
265
     * @return array
266
     */
267
    public function getUsedAdditionalFilters()
268
    {
269
        return $this->usedAdditionalFilters;
270 42
    }
271
272 42
    /**
273 42
     * @param Query $usedQuery
274
     */
275
    public function setUsedQuery($usedQuery)
276
    {
277
        $this->usedQuery = $usedQuery;
278
    }
279
280 31
    /**
281
     * Retrieves the query object that has been used to build this result set.
282 31
     *
283
     * @return Query
284
     */
285
    public function getUsedQuery()
286
    {
287
        return $this->usedQuery;
288
    }
289
290
    /**
291
     * @param int $page
292
     */
293
    public function setUsedPage($page)
294
    {
295
        $this->usedPage = $page;
296 88
    }
297
298 88
    /**
299 88
     * Retrieve the page argument that has been used to build this SearchResultSet.
300
     *
301
     * @return int
302
     */
303
    public function getUsedPage()
304
    {
305
        return $this->usedPage;
306 87
    }
307
308 87
    /**
309
     * @param \ApacheSolrForTypo3\Solr\Domain\Search\SearchRequest $usedSearchRequest
310
     */
311
    public function setUsedSearchRequest($usedSearchRequest)
312
    {
313
        $this->usedSearchRequest = $usedSearchRequest;
314 42
    }
315
316 42
    /**
317 42
     * Retrieves the SearchRequest that has been used to build this SearchResultSet.
318
     *
319
     * @return \ApacheSolrForTypo3\Solr\Domain\Search\SearchRequest
320
     */
321
    public function getUsedSearchRequest()
322 33
    {
323
        return $this->usedSearchRequest;
324 33
    }
325
326
    /**
327
     * @param \ApacheSolrForTypo3\Solr\Search $usedSearch
328
     */
329
    public function setUsedSearch($usedSearch)
330 42
    {
331
        $this->usedSearch = $usedSearch;
332 42
    }
333 42
334
    /**
335
     * @return \ApacheSolrForTypo3\Solr\Search
336
     */
337
    public function getUsedSearch()
338 26
    {
339
        return $this->usedSearch;
340 26
    }
341
342
    /**
343
     * @param int $usedResultsPerPage
344
     */
345
    public function setUsedResultsPerPage($usedResultsPerPage)
346 37
    {
347
        $this->usedResultsPerPage = $usedResultsPerPage;
348 37
    }
349
350
    /**
351
     * @return int
352
     */
353
    public function getUsedResultsPerPage()
354 42
    {
355
        return $this->usedResultsPerPage;
356 42
    }
357 42
358
    /**
359
     * @return SearchResultCollection
360
     */
361
    public function getSearchResults()
362
    {
363
        return $this->searchResults;
364
    }
365
366
    /**
367
     * @param SearchResultCollection $searchResults
368
     */
369
    public function setSearchResults($searchResults)
370 30
    {
371
        $this->searchResults = $searchResults;
372 30
    }
373
374
    /**
375
     * @param SearchResult $searchResult
376
     */
377
    public function addSearchResult(SearchResult $searchResult)
378 1
    {
379
        $this->searchResults[] = $searchResult;
380 1
    }
381 1
382
    /**
383
     * @return boolean
384
     */
385
    public function getIsAutoCorrected()
386 1
    {
387
        return $this->isAutoCorrected;
388 1
    }
389
390
    /**
391
     * @param boolean $wasAutoCorrected
392
     */
393
    public function setIsAutoCorrected($wasAutoCorrected)
394 1
    {
395
        $this->isAutoCorrected = $wasAutoCorrected;
396 1
    }
397 1
398
    /**
399
     * @return string
400
     */
401
    public function getInitialQueryString()
402 1
    {
403
        return $this->initialQueryString;
404 1
    }
405
406
    /**
407
     * @param string $initialQueryString
408
     */
409
    public function setInitialQueryString($initialQueryString)
410 1
    {
411
        $this->initialQueryString = $initialQueryString;
412 1
    }
413 1
414
    /**
415
     * @return string
416
     */
417
    public function getCorrectedQueryString()
418
    {
419
        return $this->correctedQueryString;
420
    }
421
422
    /**
423
     * @param string $correctedQueryString
424
     */
425
    public function setCorrectedQueryString($correctedQueryString)
426
    {
427
        $this->correctedQueryString = $correctedQueryString;
428
    }
429
430
    /**
431
     * @return boolean
432
     */
433
    public function getHasSearched(): bool
434
    {
435
        return $this->hasSearched;
436
    }
437
438
    /**
439
     * @param boolean $hasSearched
440
     */
441
    public function setHasSearched(bool $hasSearched)
442
    {
443
        $this->hasSearched = $hasSearched;
444
    }
445
}
446