Passed
Pull Request — master (#2871)
by
unknown
29:13
created

SearchResult::getVariantsNumFound()   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

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result;
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\ResultSet\Grouping\GroupItem;
29
use ApacheSolrForTypo3\Solr\System\Solr\Document\Document;
30
31
/**
32
 * Solr document class that should be used in the frontend in the search context.
33
 *
34
 * @author Timo Schmidt <[email protected]>
35
 */
36
class SearchResult extends Document
37
{
38
    /**
39
     * The variant field value
40
     *
41
     * Value of Solr collapse field, which is defined via
42
     * TypoScript variable "variants.variantField"
43
     *
44
     * @var string
45
     */
46
    protected $variantFieldValue = '';
47
48
    /**
49
     * Number of variants found
50
     *
51
     * May differ from documents in variants as
52
     * returned variants are limited by expand.rows
53
     *
54
     * @var int
55
     */
56
    protected $variantsNumFound = 0;
57
58
    /**
59
     * @var SearchResult[]
60
     */
61
    protected $variants = [];
62
63
    /**
64
     * Indicates if an instance of this document is a variant (a sub document of another).
65
     *
66
     * @var bool
67
     */
68
    protected $isVariant = false;
69
70
    /**
71
     * References the parent document of the document is a variant.
72
     *
73
     * @var SearchResult|null
74
     */
75
    protected $variantParent = null;
76
77
    /**
78
     * @var GroupItem
79
     */
80
    protected $groupItem = null;
81
82
83
    /**
84
     * @return GroupItem
85
     */
86
    public function getGroupItem(): GroupItem
87
    {
88
        return $this->groupItem;
89
    }
90
91
    /**
92
     * @return bool
93
     */
94
    public function getHasGroupItem()
95
    {
96
        return $this->groupItem !== null;
97
    }
98
99
    /**
100
     * @param GroupItem $group
101
     */
102
    public function setGroupItem(GroupItem $group)
103
    {
104
        $this->groupItem = $group;
105
    }
106
107
    /**
108
     * @return string
109
     */
110 1
    public function getVariantFieldValue(): string
111
    {
112 1
        return $this->variantFieldValue;
113
    }
114
115
    /**
116
     * @param string $variantFieldValue
117
     */
118 3
    public function setVariantFieldValue(string $variantFieldValue)
119
    {
120 3
        $this->variantFieldValue = $variantFieldValue;
121 3
    }
122
123
    /**
124
     * @return int
125
     */
126 1
    public function getVariantsNumFound(): int
127
    {
128 1
        return $this->variantsNumFound;
129
    }
130
131
    /**
132
     * @param int $numFound
133
     */
134 3
    public function setVariantsNumFound(int $numFound)
135
    {
136 3
        $this->variantsNumFound = $numFound;
137 3
    }
138
139
    /**
140
     * @return SearchResult[]
141
     */
142 3
    public function getVariants()
143
    {
144 3
        return $this->variants;
145
    }
146
147
    /**
148
     * @param SearchResult $expandedResult
149
     */
150 3
    public function addVariant(SearchResult $expandedResult)
151
    {
152 3
        $this->variants[] = $expandedResult;
153 3
    }
154
155
    /**
156
     * @return bool
157
     */
158 2
    public function getIsVariant()
159
    {
160 2
        return $this->isVariant;
161
    }
162
163
    /**
164
     * @param bool $isVariant
165
     */
166 3
    public function setIsVariant($isVariant)
167
    {
168 3
        $this->isVariant = $isVariant;
169 3
    }
170
171
    /**
172
     * @return SearchResult
173
     */
174 1
    public function getVariantParent()
175
    {
176 1
        return $this->variantParent;
177
    }
178
179
    /**
180
     * @param SearchResult $variantParent
181
     */
182 3
    public function setVariantParent(SearchResult $variantParent)
183
    {
184 3
        $this->variantParent = $variantParent;
185 3
    }
186
187
    /**
188
     * @return string
189
     */
190 1
    public function getContent()
191
    {
192 1
        return $this->fields['content'];
193
    }
194
195
    /**
196
     * @return boolean
197
     */
198 1
    public function getIsElevated()
199
    {
200 1
        return $this->fields['isElevated'];
201
    }
202
203
    /**
204
     * @return string
205
     */
206 2
    public function getType()
207
    {
208 2
        return $this->fields['type'];
209
    }
210
211
    /**
212
     * @return integer
213
     */
214 1
    public function getId()
215
    {
216 1
        return $this->fields['id'];
217
    }
218
219
    /**
220
     * @return float
221
     */
222 1
    public function getScore()
223
    {
224 1
        return $this->fields['score'];
225
    }
226
227
    /**
228
     * @return string
229
     */
230 1
    public function getUrl()
231
    {
232 1
        return $this->fields['url'];
233
    }
234
235
    /**
236
     * @return string
237
     */
238 3
    public function getTitle()
239
    {
240 3
        return $this->fields['title'];
241
    }
242
}
243