Passed
Push — master ( 3cd8c6...9e747f )
by Timo
38:54 queued 16:17
created

SearchResult::getContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet;
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 2 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
/**
29
 * Proxy class for \Apache_Solr_Document to customize \Apache_Solr_Document without
30
 * changing the library code.
31
 *
32
 * Implements
33
 *
34
 * @author Timo Schmidt <[email protected]>
35
 */
36
class SearchResult extends \Apache_Solr_Document
37
{
38
39
    /**
40
     * @var bool
41
     */
42
    protected $throwExceptions = false;
43
44
    /**
45
     * @var SearchResult[]
46
     */
47
    protected $variants = [];
48
49
    /**
50
     * Indicates if an instance of this document is a variant (a sub document of another).
51
     *
52
     * @var bool
53
     */
54
    protected $isVariant = false;
55
56
    /**
57
     * References the parent document of the document is a variant.
58
     *
59
     * @var null
60
     */
61
    protected $variantParent = null;
62
63
    /**
64
     * @param \Apache_Solr_Document $document
65
     * @param bool $throwExceptions
66
     */
67 35
    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.

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

Loading history...
68
    {
69 35
        $this->throwExceptions = false;
70 35
        $this->_documentBoost = $document->_documentBoost;
71 35
        $this->_fields = $document->_fields;
72 35
        $this->_fieldBoosts = $document->_fieldBoosts;
73 35
    }
74
75
    /**
76
     * @param string $name
77
     * @param array $arguments
78
     * @throws \Exception
79
     * @throws \RuntimeException
80
     * @return string
81
     */
82
    public function __call($name, $arguments)
83
    {
84
        try {
85
            return parent::__call($name, $arguments);
86
        } catch (\RuntimeException $e) {
87
            if ($this->throwExceptions) {
88
                throw $e;
89
            }
90
        }
91
    }
92
93
    /**
94
     * @return SearchResult[]
95
     */
96 2
    public function getVariants()
97
    {
98 2
        return $this->variants;
99
    }
100
101
    /**
102
     * @param SearchResult $expandedResult
103
     */
104 2
    public function addVariant(SearchResult $expandedResult)
105
    {
106 2
        $this->variants[] = $expandedResult;
107 2
    }
108
109
    /**
110
     * @return bool
111
     */
112 1
    public function getIsVariant()
113
    {
114 1
        return $this->isVariant;
115
    }
116
117
    /**
118
     * @param bool $isVariant
119
     */
120 2
    public function setIsVariant($isVariant)
121
    {
122 2
        $this->isVariant = $isVariant;
123 2
    }
124
125
    /**
126
     * @return null
127
     */
128
    public function getVariantParent()
129
    {
130
        return $this->variantParent;
131
    }
132
133
    /**
134
     * @param null $variantParent
135
     */
136 2
    public function setVariantParent($variantParent)
137
    {
138 2
        $this->variantParent = $variantParent;
139 2
    }
140
141
    /**
142
     * @return string
143
     */
144 23
    public function getContent()
145
    {
146 23
        return $this->_fields['content'];
147
    }
148
149
    /**
150
     * @return boolean
151
     */
152 22
    public function getIsElevated()
153
    {
154 22
        return $this->_fields['isElevated'];
155
    }
156
157
    /**
158
     * @return string
159
     */
160 22
    public function getType()
161
    {
162 22
        return $this->_fields['type'];
163
    }
164
165
    /**
166
     * @return integer
167
     */
168 22
    public function getId()
169
    {
170 22
        return $this->_fields['id'];
171
    }
172
173
    /**
174
     * @return float
175
     */
176 22
    public function getScore()
177
    {
178 22
        return $this->_fields['score'];
179
    }
180
181
    /**
182
     * @return string
183
     */
184 23
    public function getUrl()
185
    {
186 23
        return $this->_fields['url'];
187
    }
188
189
    /**
190
     * @return string
191
     */
192 25
    public function getTitle()
193
    {
194 25
        return $this->_fields['title'];
195
    }
196
}
197