Passed
Push — master ( bd2c53...55d092 )
by Timo
22:59 queued 50s
created

SearchResultSet::getCorrectedQueryString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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 2 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\ResultSet\Facets\AbstractFacet;
29
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\FacetCollection;
30
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Sorting\Sorting;
31
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Sorting\SortingCollection;
32
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Spellchecking\Suggestion;
33
use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequest;
34
use ApacheSolrForTypo3\Solr\Query;
35
use ApacheSolrForTypo3\Solr\Search;
36
37
/**
38
 * The SearchResultSet is used to provided access to the \Apache_Solr_Response and
39
 * other relevant information, like the used Query and Request objects.
40
 *
41
 * @author Timo Schmidt <[email protected]>
42
 */
43
class SearchResultSet
44
{
45
46
    /**
47
     * @var Query
48
     */
49
    protected $usedQuery = null;
50
51
    /**
52
     * @var SearchRequest
53
     */
54
    protected $usedSearchRequest = null;
55
56
    /**
57
     * @var Search
58
     */
59
    protected $usedSearch;
60
61
    /**
62
     * @var \Apache_Solr_Response
63
     */
64
    protected $response = null;
65
66
    /**
67
     * @var int
68
     */
69
    protected $usedPage = 0;
70
71
    /**
72
     * @var int
73
     */
74
    protected $usedResultsPerPage = 0;
75
76
    /**
77
     * @var array
78
     */
79
    protected $usedAdditionalFilters = [];
80
81
    /**
82
     * @var array
83
     */
84
    protected $searchResults = [];
85
86
    /**
87
     * @var int
88
     */
89
    protected $allResultCount = 0;
90
91
    /**
92
     * @var Suggestion[]
93
     */
94
    protected $spellCheckingSuggestions = [];
95
96
    /**
97
     * @var FacetCollection
98
     */
99
    protected $facets = null;
100
101
    /**
102
     * @var SortingCollection
103
     */
104
    protected $sortings = null;
105
106
    /**
107
     * @var bool
108
     */
109
    protected $isAutoCorrected = false;
110
111
    /**
112
     * @var string
113
     */
114
    protected $initialQueryString = '';
115
116
    /**
117
     * @var string
118
     */
119
    protected $correctedQueryString = '';
120
121
    /**
122
     * @return \ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
123
     */
124 86
    public function __construct()
125
    {
126 86
        $this->facets = new FacetCollection();
127 86
        $this->sortings = new SortingCollection();
128 86
    }
129
130
    /**
131
     * @param int $allResultCount
132
     */
133 60
    public function setAllResultCount($allResultCount)
134
    {
135 60
        $this->allResultCount = $allResultCount;
136 60
    }
137
138
    /**
139
     * @return int
140
     */
141 27
    public function getAllResultCount()
142
    {
143 27
        return $this->allResultCount;
144
    }
145
146
    /**
147
     * @param Suggestion $suggestion
148
     */
149 5
    public function addSpellCheckingSuggestion(Suggestion $suggestion)
150
    {
151 5
        $this->spellCheckingSuggestions[$suggestion->getSuggestion()] = $suggestion;
152 5
    }
153
154
    /**
155
     * @return bool
156
     */
157 30
    public function getHasSpellCheckingSuggestions()
158
    {
159 30
        return count($this->spellCheckingSuggestions) > 0;
160
    }
161
162
    /**
163
     * @param \ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Spellchecking\Suggestion[] $spellCheckingSuggestions
164
     */
165
    public function setSpellCheckingSuggestions($spellCheckingSuggestions)
166
    {
167
        $this->spellCheckingSuggestions = $spellCheckingSuggestions;
168
    }
169
170
    /**
171
     * @return \ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Spellchecking\Suggestion[]
172
     */
173 4
    public function getSpellCheckingSuggestions()
174
    {
175 4
        return $this->spellCheckingSuggestions;
176
    }
177
178
    /**
179
     * @return FacetCollection
180
     */
181 59
    public function getFacets()
182
    {
183 59
        return $this->facets;
184
    }
185
186
    /**
187
     * @param AbstractFacet $facet
188
     */
189 55
    public function addFacet(AbstractFacet $facet)
190
    {
191 55
        $this->facets->addFacet($facet);
192 55
    }
193
194
    /**
195
     * @param Sorting $sorting
196
     */
197 29
    public function addSorting(Sorting $sorting)
198
    {
199 29
        $this->sortings->addSorting($sorting);
200 29
    }
201
202
    /**
203
     * @return SortingCollection
204
     */
205 29
    public function getSortings()
206
    {
207 29
        return $this->sortings;
208
    }
209
210
    /**
211
     * @param \Apache_Solr_Response $response
212
     */
213 78
    public function setResponse($response)
214
    {
215 78
        $this->response = $response;
216 78
    }
217
218
    /**
219
     * @return \Apache_Solr_Response
220
     */
221 78
    public function getResponse()
222
    {
223 78
        return $this->response;
224
    }
225
226
    /**
227
     * @param array $usedAdditionalFilters
228
     */
229 38
    public function setUsedAdditionalFilters($usedAdditionalFilters)
230
    {
231 38
        $this->usedAdditionalFilters = $usedAdditionalFilters;
232 38
    }
233
234
    /**
235
     * @return array
236
     */
237
    public function getUsedAdditionalFilters()
238
    {
239
        return $this->usedAdditionalFilters;
240
    }
241
242
    /**
243
     * @param \ApacheSolrForTypo3\Solr\Query $usedQuery
244
     */
245 38
    public function setUsedQuery($usedQuery)
246
    {
247 38
        $this->usedQuery = $usedQuery;
248 38
    }
249
250
    /**
251
     * Retrieves the query object that has been used to build this result set.
252
     *
253
     * @return \ApacheSolrForTypo3\Solr\Query
254
     */
255 30
    public function getUsedQuery()
256
    {
257 30
        return $this->usedQuery;
258
    }
259
260
    /**
261
     * @param int $page
262
     */
263 38
    public function setUsedPage($page)
264
    {
265 38
        $this->usedPage = $page;
266 38
    }
267
268
    /**
269
     * Retrieve the page argument that has been used to build this SearchResultSet.
270
     *
271
     * @return int
272
     */
273 27
    public function getUsedPage()
274
    {
275 27
        return $this->usedPage;
276
    }
277
278
    /**
279
     * @return int
280
     */
281
    public function getResultsPerPage()
282
    {
283
        return $this->usedQuery->getResultsPerPage();
284
    }
285
286
    /**
287
     * @param \ApacheSolrForTypo3\Solr\Domain\Search\SearchRequest $usedSearchRequest
288
     */
289 81
    public function setUsedSearchRequest($usedSearchRequest)
290
    {
291 81
        $this->usedSearchRequest = $usedSearchRequest;
292 81
    }
293
294
    /**
295
     * Retrieves the SearchRequest that has been used to build this SearchResultSet.
296
     *
297
     * @return \ApacheSolrForTypo3\Solr\Domain\Search\SearchRequest
298
     */
299 81
    public function getUsedSearchRequest()
300
    {
301 81
        return $this->usedSearchRequest;
302
    }
303
304
    /**
305
     * @param \ApacheSolrForTypo3\Solr\Search $usedSearch
306
     */
307 38
    public function setUsedSearch($usedSearch)
308
    {
309 38
        $this->usedSearch = $usedSearch;
310 38
    }
311
312
    /**
313
     * @return \ApacheSolrForTypo3\Solr\Search
314
     */
315 29
    public function getUsedSearch()
316
    {
317 29
        return $this->usedSearch;
318
    }
319
320
    /**
321
     * @param int $usedResultsPerPage
322
     */
323 38
    public function setUsedResultsPerPage($usedResultsPerPage)
324
    {
325 38
        $this->usedResultsPerPage = $usedResultsPerPage;
326 38
    }
327
328
    /**
329
     * @return int
330
     */
331 22
    public function getUsedResultsPerPage()
332
    {
333 22
        return $this->usedResultsPerPage;
334
    }
335
336
    /**
337
     * @return array
338
     */
339 4
    public function getSearchResults()
340
    {
341 4
        return $this->searchResults;
342
    }
343
344
    /**
345
     * @param array $searchResults
346
     */
347
    public function setSearchResults($searchResults)
348
    {
349
        $this->searchResults = $searchResults;
350
    }
351
352
    /**
353
     * @param SearchResult $searchResult
354
     */
355 27
    public function addSearchResult(SearchResult $searchResult)
356
    {
357 27
        $this->searchResults[] = $searchResult;
358 27
    }
359
360
    /**
361
     * @return boolean
362
     */
363 26
    public function getIsAutoCorrected()
364
    {
365 26
        return $this->isAutoCorrected;
366
    }
367
368
    /**
369
     * @param boolean $wasAutoCorrected
370
     */
371 1
    public function setIsAutoCorrected($wasAutoCorrected)
372
    {
373 1
        $this->isAutoCorrected = $wasAutoCorrected;
374 1
    }
375
376
    /**
377
     * @return string
378
     */
379 1
    public function getInitialQueryString()
380
    {
381 1
        return $this->initialQueryString;
382
    }
383
384
    /**
385
     * @param string $initialQueryString
386
     */
387 1
    public function setInitialQueryString($initialQueryString)
388
    {
389 1
        $this->initialQueryString = $initialQueryString;
390 1
    }
391
392
    /**
393
     * @return string
394
     */
395 1
    public function getCorrectedQueryString()
396
    {
397 1
        return $this->correctedQueryString;
398
    }
399
400
    /**
401
     * @param string $correctedQueryString
402
     */
403 1
    public function setCorrectedQueryString($correctedQueryString)
404
    {
405 1
        $this->correctedQueryString = $correctedQueryString;
406 1
    }
407
}
408