Passed
Push — master ( 4e40a2...cc3f84 )
by Timo
24:09
created

GroupItem::getAllResultCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.037

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 3
cp 0.6667
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1.037
1
<?php
2
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2017 Timo Hund <[email protected]>
8
 *  All rights reserved
9
 *
10
 *  This script is part of the TYPO3 project. The TYPO3 project is
11
 *  free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 3 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  The GNU General Public License can be found at
17
 *  http://www.gnu.org/copyleft/gpl.html.
18
 *
19
 *  This script is distributed in the hope that it will be useful,
20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 *  GNU General Public License for more details.
23
 *
24
 *  This copyright notice MUST APPEAR in all copies of the script!
25
 ***************************************************************/
26
27
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\SearchResult;
28
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\SearchResultCollection;
29
30
/**
31
 * Class GroupItem
32
 *
33
 * @author Frans Saris <[email protected]>
34
 * @author Timo Hund <[email protected]>
35
 * @package ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping
36
 */
37
class GroupItem
38
{
39
    /**
40
     * @var string
41
     */
42
    protected $groupValue = '';
43
44
    /**
45
     * @var int
46
     */
47
    protected $allResultCount = 0;
48
49
    /**
50
     * @var int
51
     */
52
    protected $start = 0;
53
54
    /**
55
     * @var float
56
     */
57
    protected $maximumScore = 0;
58
59
    /**
60
     * @var SearchResultCollection
61
     */
62
    protected $searchResults;
63
64
    /**
65
     * @var Group
66
     */
67
    protected $group;
68
69
    /**
70
     * @param Group $group
71
     * @param string $groupValue
72
     * @param int $numFound
73
     * @param int $start
74
     * @param float $maxScore
75
     */
76 9
    public function __construct(Group $group, $groupValue, $numFound, $start, $maxScore)
77
    {
78 9
        $this->group = $group;
79 9
        $this->groupValue = $groupValue;
80 9
        $this->allResultCount = $numFound;
81 9
        $this->start = $start;
82 9
        $this->maximumScore = $maxScore;
83 9
        $this->searchResults = new SearchResultCollection();
84 9
    }
85
86
    /**
87
     * Get groupValue
88
     *
89
     * @return string
90
     */
91 2
    public function getGroupValue()
92
    {
93 2
        return $this->groupValue;
94
    }
95
96
    /**
97
     * Get numFound
98
     *
99
     * @return int
100
     */
101 1
    public function getAllResultCount()
102
    {
103 1
        return $this->allResultCount;
104
    }
105
106
    /**
107
     * Get numFound
108
     *
109
     * @deprecated Deprecated since EXT:solr 9.0.0 will be removed in EXT:solr 10.0.0 use getAllResultCount now
110
     * @return int
111
     */
112
    public function getNumFound()
113
    {
114
        trigger_error('GroupItem::getNumFound is deprecated please use GroupItem::getAllResultCount now', E_USER_DEPRECATED);
115
        return $this->getAllResultCount();
116
    }
117
118
    /**
119
     * Get start
120
     *
121
     * @return int
122
     */
123 1
    public function getStart()
124
    {
125 1
        return $this->start;
126
    }
127
128
    /**
129
     * Get maxScore
130
     *
131
     * @return float
132
     */
133 1
    public function getMaximumScore()
134
    {
135 1
        return $this->maximumScore;
136
    }
137
138
    /**
139
     * Get maxScore
140
     *
141
     * @deprecated Deprecated since EXT:solr 9.0.0 will be removed in EXT:solr 10.0.0 getMaximumScore now
142
     * @return float
143
     */
144
    public function getMaxScore()
145
    {
146
        trigger_error('GroupItem::getMaxScore is deprecated please use GroupItem::getMaximumScore now', E_USER_DEPRECATED);
147
        return $this->getMaximumScore();
148
    }
149
150
151
    /**
152
     * @return SearchResultCollection
153
     */
154 1
    public function getSearchResults(): SearchResultCollection
155
    {
156 1
        return $this->searchResults;
157
    }
158
159
    /**
160
     * @param SearchResultCollection $searchResults
161
     */
162
    public function setSearchResults(SearchResultCollection $searchResults)
163
    {
164
        $this->searchResults = $searchResults;
165
    }
166
167
    /**
168
     * @param SearchResult $searchResult
169
     */
170 1
    public function addSearchResult(SearchResult $searchResult)
171
    {
172 1
        $this->searchResults[] = $searchResult;
173 1
    }
174
175
    /**
176
     * @return Group
177
     */
178 2
    public function getGroup(): Group
179
    {
180 2
        return $this->group;
181
    }
182
}
183