Passed
Push — master ( d33ff5...5cb25b )
by Timo
20:06
created

GroupItem::getMaximumScore()   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 $numFound = 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->numFound = $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 getNumFound()
102
    {
103 1
        return $this->numFound;
104
    }
105
106
    /**
107
     * Get start
108
     *
109
     * @return int
110
     */
111 1
    public function getStart()
112
    {
113 1
        return $this->start;
114
    }
115
116
    /**
117
     * Get maxScore
118
     *
119
     * @return float
120
     */
121 1
    public function getMaximumScore()
122
    {
123 1
        return $this->maximumScore;
124
    }
125
126
    /**
127
     * Get maxScore
128
     *
129
     * @deprecated Deprecated since EXT:solr 9.0.0 will be removed in EXT:solr 10.0.0
130
     * @return float
131
     */
132
    public function getMaxScore()
133
    {
134
        trigger_error('GroupItem::getMaxScore is deprecated please use GroupItem::getMaximumScore now', E_USER_DEPRECATED);
135
        return $this->getMaximumScore();
136
    }
137
138
139
    /**
140
     * @return SearchResultCollection
141
     */
142 1
    public function getSearchResults(): SearchResultCollection
143
    {
144 1
        return $this->searchResults;
145
    }
146
147
    /**
148
     * @param SearchResultCollection $searchResults
149
     */
150
    public function setSearchResults(SearchResultCollection $searchResults)
151
    {
152
        $this->searchResults = $searchResults;
153
    }
154
155
    /**
156
     * @param SearchResult $searchResult
157
     */
158 1
    public function addSearchResult(SearchResult $searchResult)
159
    {
160 1
        $this->searchResults[] = $searchResult;
161 1
    }
162
163
    /**
164
     * @return Group
165
     */
166 2
    public function getGroup(): Group
167
    {
168 2
        return $this->group;
169
    }
170
}
171