Completed
Push — master ( dedf8a...55d092 )
by Timo
33:39
created

SearchResultSet::setUsedPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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