Passed
Pull Request — master (#72)
by
unknown
08:48
created

Highlight::getWidth()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
5
 *
6
 * This file is part of the Kitodo and TYPO3 projects.
7
 *
8
 * @license GNU General Public License version 3 or later.
9
 * For the full copyright and license information, please read the
10
 * LICENSE.txt file that was distributed with this source code.
11
 */
12
13
namespace Kitodo\Dlf\Common\SolrSearchResult;
14
15
/**
16
 * Highlight class for the 'dlf' extension. It keeps highlight for found search phrase.
17
 *
18
 * @author Beatrycze Volk <[email protected]>
19
 * @package TYPO3
20
 * @subpackage dlf
21
 * @access public
22
 */
23
class Highlight
24
{
25
26
    /**
27
     * The identifier in form 'w_h_x_y'
28
     *
29
     * @var string
30
     * @access private
31
     */
32
    private $id;
33
34
    /**
35
     * The parent region's identifier
36
     *
37
     * @var int
38
     * @access private
39
     */
40
    private $parentRegionId;
41
42
    /**
43
     * The horizontal beginning position of found highlight
44
     *
45
     * @var int
46
     * @access private
47
     */
48
    private $xBeginPosition;
49
50
    /**
51
     * The horizontal ending position of found highlight
52
     *
53
     * @var int
54
     * @access private
55
     */
56
    private $xEndPosition;
57
58
    /**
59
     * The vertical beginning position of found highlight
60
     *
61
     * @var int
62
     * @access private
63
     */
64
    private $yBeginPosition;
65
66
    /**
67
     * The vertical ending position of found highlight
68
     *
69
     * @var int
70
     * @access private
71
     */
72
    private $yEndPosition;
73
74
    /**
75
     * The width of found highlight
76
     *
77
     * @var int
78
     * @access private
79
     */
80
    private $width;
81
82
    /**
83
     * The height of found highlight
84
     *
85
     * @var int
86
     * @access private
87
     */
88
    private $height;
89
90
    /**
91
     * The constructor for highlight.
92
     *
93
     * @access public
94
     *
95
     * @param array $highlight: Array of found highlight properties
96
     *
97
     * @return void
98
     */
99
    public function __construct($highlight)
100
    {
101
        $this->parentRegionId = $highlight['parentRegionIdx'];
102
        $this->xBeginPosition = $highlight['ulx'];
103
        $this->xEndPosition = $highlight['lrx'];
104
        $this->yBeginPosition = $highlight['uly'];
105
        $this->yEndPosition = $highlight['lry'];
106
        $this->width = $highlight['lrx'] - $highlight['ulx'];
107
        $this->height = $highlight['lry'] - $highlight['uly'];
108
        $this->id = $this->width . '_' . $this->height . '_' . $this->xBeginPosition . '_' . $this->yBeginPosition;
109
    }
110
111
    /**
112
     * Get the highlight's identifier.
113
     *
114
     * @access public
115
     *
116
     * @return string The highlight's identifier
117
     */
118
    public function getId()
119
    {
120
        return $this->id;
121
    }
122
123
    /**
124
     * Get the highlight's horizontal beginning position.
125
     *
126
     * @access public
127
     *
128
     * @return int The highlight's horizontal beginning position
129
     */
130
    public function getXBeginPosition()
131
    {
132
        return $this->xBeginPosition;
133
    }
134
135
    /**
136
     * Get the highlight's horizontal ending position.
137
     *
138
     * @access public
139
     *
140
     * @return int The highlight's horizontal ending position
141
     */
142
    public function getXEndPosition()
143
    {
144
        return $this->xEndPosition;
145
    }
146
147
    /**
148
     * Get the highlight's vertical beginning position.
149
     *
150
     * @access public
151
     *
152
     * @return int The highlight's vertical beginning position
153
     */
154
    public function getYBeginPosition()
155
    {
156
        return $this->yBeginPosition;
157
    }
158
159
    /**
160
     * Get the highlight's vertical ending position.
161
     *
162
     * @access public
163
     *
164
     * @return int The highlight's vertical ending position
165
     */
166
    public function getYEndPosition()
167
    {
168
        return $this->yEndPosition;
169
    }
170
171
    /**
172
     * Get the highlight's width.
173
     *
174
     * @access public
175
     *
176
     * @return int The highlight's width
177
     */
178
    public function getWidth()
179
    {
180
        return $this->width;
181
    }
182
183
    /**
184
     * Get the highlight's height.
185
     *
186
     * @access public
187
     *
188
     * @return int The highlight's height
189
     */
190
    public function getHeight()
191
    {
192
        return $this->height;
193
    }
194
}
195