Passed
Push — master ( 17ae05...2920d4 )
by Timo
27:57
created

SearchResult   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 154
Duplicated Lines 0 %

Test Coverage

Coverage 80.56%

Importance

Changes 0
Metric Value
wmc 16
eloc 21
dl 0
loc 154
ccs 29
cts 36
cp 0.8056
rs 10
c 0
b 0
f 0

16 Methods

Rating   Name   Duplication   Size   Complexity  
A getHasGroupItem() 0 3 1
A getVariants() 0 3 1
A getVariantParent() 0 3 1
A getContent() 0 3 1
A getGroupItem() 0 3 1
A setGroupItem() 0 3 1
A addVariant() 0 3 1
A getIsVariant() 0 3 1
A getUrl() 0 3 1
A getScore() 0 3 1
A setVariantParent() 0 3 1
A getTitle() 0 3 1
A getType() 0 3 1
A getId() 0 3 1
A setIsVariant() 0 3 1
A getIsElevated() 0 3 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
    /**
40
     * @var SearchResult[]
41
     */
42
    protected $variants = [];
43
44
    /**
45
     * Indicates if an instance of this document is a variant (a sub document of another).
46
     *
47
     * @var bool
48
     */
49
    protected $isVariant = false;
50
51
    /**
52
     * References the parent document of the document is a variant.
53
     *
54
     * @var null
55
     */
56
    protected $variantParent = null;
57
58
    /**
59
     * @var GroupItem
60
     */
61
    protected $groupItem = null;
62
63
64
    /**
65
     * @return GroupItem
66
     */
67
    public function getGroupItem(): GroupItem
68
    {
69
        return $this->groupItem;
70
    }
71
72
    /**
73
     * @return bool
74
     */
75 1
    public function getHasGroupItem()
76
    {
77 1
        return $this->groupItem !== null;
78
    }
79
80
    /**
81
     * @param GroupItem $group
82
     */
83
    public function setGroupItem(GroupItem $group)
84
    {
85
        $this->groupItem = $group;
86
    }
87
88
    /**
89
     * @return SearchResult[]
90
     */
91 2
    public function getVariants()
92
    {
93 2
        return $this->variants;
94
    }
95
96
    /**
97
     * @param SearchResult $expandedResult
98
     */
99 2
    public function addVariant(SearchResult $expandedResult)
100
    {
101 2
        $this->variants[] = $expandedResult;
102 2
    }
103
104
    /**
105
     * @return bool
106
     */
107 1
    public function getIsVariant()
108
    {
109 1
        return $this->isVariant;
110
    }
111
112
    /**
113
     * @param bool $isVariant
114
     */
115 2
    public function setIsVariant($isVariant)
116
    {
117 2
        $this->isVariant = $isVariant;
118 2
    }
119
120
    /**
121
     * @return null
122
     */
123
    public function getVariantParent()
124
    {
125
        return $this->variantParent;
126
    }
127
128
    /**
129
     * @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...
130
     */
131 2
    public function setVariantParent($variantParent)
132
    {
133 2
        $this->variantParent = $variantParent;
134 2
    }
135
136
    /**
137
     * @return string
138
     */
139 28
    public function getContent()
140
    {
141 28
        return $this->fields['content'];
142
    }
143
144
    /**
145
     * @return boolean
146
     */
147 2
    public function getIsElevated()
148
    {
149 2
        return $this->fields['isElevated'];
150
    }
151
152
    /**
153
     * @return string
154
     */
155 3
    public function getType()
156
    {
157 3
        return $this->fields['type'];
158
    }
159
160
    /**
161
     * @return integer
162
     */
163 27
    public function getId()
164
    {
165 27
        return $this->fields['id'];
166
    }
167
168
    /**
169
     * @return float
170
     */
171 27
    public function getScore()
172
    {
173 27
        return $this->fields['score'];
174
    }
175
176
    /**
177
     * @return string
178
     */
179 2
    public function getUrl()
180
    {
181 2
        return $this->fields['url'];
182
    }
183
184
    /**
185
     * @return string
186
     */
187 4
    public function getTitle()
188
    {
189 4
        return $this->fields['title'];
190
    }
191
}
192