Passed
Push — master ( f3b3b6...d83d48 )
by Timo
23:16
created

SearchResult::getGroupItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 2
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
30
/**
31
 * Proxy class for \Apache_Solr_Document to customize \Apache_Solr_Document without
32
 * changing the library code.
33
 *
34
 * Implements
35
 *
36
 * @author Timo Schmidt <[email protected]>
37
 */
38
class SearchResult extends \Apache_Solr_Document
39
{
40
41
    /**
42
     * @var bool
43
     */
44
    protected $throwExceptions = false;
45
46
    /**
47
     * @var SearchResult[]
48
     */
49
    protected $variants = [];
50
51
    /**
52
     * Indicates if an instance of this document is a variant (a sub document of another).
53
     *
54
     * @var bool
55
     */
56
    protected $isVariant = false;
57
58
    /**
59
     * References the parent document of the document is a variant.
60
     *
61
     * @var null
62
     */
63
    protected $variantParent = null;
64
65
    /**
66
     * @var GroupItem
67
     */
68
    protected $groupItem = null;
69
70
    /**
71
     * @param \Apache_Solr_Document $document
72
     * @param bool $throwExceptions
73
     */
74 42
    public function __construct(\Apache_Solr_Document $document, $throwExceptions = false)
0 ignored issues
show
Unused Code introduced by
The parameter $throwExceptions is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

74
    public function __construct(\Apache_Solr_Document $document, /** @scrutinizer ignore-unused */ $throwExceptions = false)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
75
    {
76 42
        $this->throwExceptions = false;
77 42
        $this->_documentBoost = $document->_documentBoost;
78 42
        $this->_fields = $document->_fields;
79 42
        $this->_fieldBoosts = $document->_fieldBoosts;
80 42
    }
81
82
    /**
83
     * @param string $name
84
     * @param array $arguments
85
     * @throws \Exception
86
     * @throws \RuntimeException
87
     * @return string
88
     */
89
    public function __call($name, $arguments)
90
    {
91
        try {
92
            return parent::__call($name, $arguments);
93
        } catch (\RuntimeException $e) {
94
            if ($this->throwExceptions) {
95
                throw $e;
96
            }
97
        }
98
    }
99
100
    /**
101
     * @return GroupItem
102
     */
103
    public function getGroupItem(): GroupItem
104
    {
105
        return $this->groupItem;
106
    }
107
108
    /**
109
     * @return bool
110
     */
111
    public function getHasGroupItem()
112
    {
113
        return $this->groupItem !== null;
114
    }
115
116
    /**
117
     * @param GroupItem $group
118
     */
119
    public function setGroupItem(GroupItem $group)
120
    {
121
        $this->groupItem = $group;
122
    }
123
124
    /**
125
     * @return SearchResult[]
126
     */
127 2
    public function getVariants()
128
    {
129 2
        return $this->variants;
130
    }
131
132
    /**
133
     * @param SearchResult $expandedResult
134
     */
135 2
    public function addVariant(SearchResult $expandedResult)
136
    {
137 2
        $this->variants[] = $expandedResult;
138 2
    }
139
140
    /**
141
     * @return bool
142
     */
143 1
    public function getIsVariant()
144
    {
145 1
        return $this->isVariant;
146
    }
147
148
    /**
149
     * @param bool $isVariant
150
     */
151 2
    public function setIsVariant($isVariant)
152
    {
153 2
        $this->isVariant = $isVariant;
154 2
    }
155
156
    /**
157
     * @return null
158
     */
159
    public function getVariantParent()
160
    {
161
        return $this->variantParent;
162
    }
163
164
    /**
165
     * @param null $variantParent
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $variantParent is correct as it would always require null to be passed?
Loading history...
166
     */
167 2
    public function setVariantParent($variantParent)
168
    {
169 2
        $this->variantParent = $variantParent;
170 2
    }
171
172
    /**
173
     * @return string
174
     */
175 28
    public function getContent()
176
    {
177 28
        return $this->_fields['content'];
178
    }
179
180
    /**
181
     * @return boolean
182
     */
183 27
    public function getIsElevated()
184
    {
185 27
        return $this->_fields['isElevated'];
186
    }
187
188
    /**
189
     * @return string
190
     */
191 28
    public function getType()
192
    {
193 28
        return $this->_fields['type'];
194
    }
195
196
    /**
197
     * @return integer
198
     */
199 27
    public function getId()
200
    {
201 27
        return $this->_fields['id'];
202
    }
203
204
    /**
205
     * @return float
206
     */
207 27
    public function getScore()
208
    {
209 27
        return $this->_fields['score'];
210
    }
211
212
    /**
213
     * @return string
214
     */
215 28
    public function getUrl()
216
    {
217 28
        return $this->_fields['url'];
218
    }
219
220
    /**
221
     * @return string
222
     */
223 30
    public function getTitle()
224
    {
225 30
        return $this->_fields['title'];
226
    }
227
}
228