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

Region::getXEndPosition()   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
 * Region class for the 'dlf' extension. It keeps region in which search phrase was found.
17
 *
18
 * @author Beatrycze Volk <[email protected]>
19
 * @package TYPO3
20
 * @subpackage dlf
21
 * @access public
22
 */
23
class Region
24
{
25
26
    /**
27
     * The identifier of the region
28
     *
29
     * @var int
30
     * @access private
31
     */
32
    private $id;
33
34
    /**
35
     * The identifier of the page in which text was found
36
     *
37
     * @var int
38
     * @access private
39
     */
40
    private $pageId;
41
42
    /**
43
     * The horizontal beginning position of found region
44
     *
45
     * @var int
46
     * @access private
47
     */
48
    private $xBeginPosition;
49
50
    /**
51
     * The horizontal ending position of found region
52
     *
53
     * @var int
54
     * @access private
55
     */
56
    private $xEndPosition;
57
58
    /**
59
     * The vertical beginning position of found region
60
     *
61
     * @var int
62
     * @access private
63
     */
64
    private $yBeginPosition;
65
66
    /**
67
     * The vertical ending position of found region
68
     *
69
     * @var int
70
     * @access private
71
     */
72
    private $yEndPosition;
73
74
    /**
75
     * The width of found region
76
     *
77
     * @var int
78
     * @access private
79
     */
80
    private $width;
81
82
    /**
83
     * The height of found region
84
     *
85
     * @var int
86
     * @access private
87
     */
88
    private $height;
89
90
    /**
91
     * The text of found region
92
     *
93
     * @var string
94
     * @access private
95
     */
96
    private $text;
97
98
    /**
99
     * The constructor for region.
100
     *
101
     * @access public
102
     *
103
     * @param int $id: Id of found region properties
104
     * @param array $region: Array of found region properties
105
     *
106
     * @return void
107
     */
108
    public function __construct($id, $region)
109
    {
110
        $this->id = $id;
111
        $this->pageId = $region['pageIdx'];
112
        $this->xBeginPosition = $region['ulx'];
113
        $this->xEndPosition = $region['lrx'];
114
        $this->yBeginPosition = $region['uly'];
115
        $this->yEndPosition = $region['lry'];
116
        $this->width = $region['lrx'] - $region['ulx'];
117
        $this->height = $region['lry'] - $region['uly'];
118
        $this->text = $region['text'];
119
    }
120
121
    /**
122
     * Get the region's identifier.
123
     *
124
     * @access public
125
     *
126
     * @return int The region's identifier
127
     */
128
    public function getId()
129
    {
130
        return $this->id;
131
    }
132
133
    /**
134
     * Get the region's page identifier.
135
     *
136
     * @access public
137
     *
138
     * @return int The region's page identifier
139
     */
140
    public function getPageId()
141
    {
142
        return $this->pageId;
143
    }
144
145
    /**
146
     * Get the region's horizontal beginning position.
147
     *
148
     * @access public
149
     *
150
     * @return int The region's horizontal beginning position
151
     */
152
    public function getXBeginPosition()
153
    {
154
        return $this->xBeginPosition;
155
    }
156
157
    /**
158
     * Get the region's horizontal ending position.
159
     *
160
     * @access public
161
     *
162
     * @return int The region's horizontal ending position
163
     */
164
    public function getXEndPosition()
165
    {
166
        return $this->xEndPosition;
167
    }
168
169
    /**
170
     * Get the region's vertical beginning position.
171
     *
172
     * @access public
173
     *
174
     * @return int The region's vertical beginning position
175
     */
176
    public function getYBeginPosition()
177
    {
178
        return $this->yBeginPosition;
179
    }
180
181
    /**
182
     * Get the region's vertical ending position.
183
     *
184
     * @access public
185
     *
186
     * @return int The region's vertical ending position
187
     */
188
    public function getYEndPosition()
189
    {
190
        return $this->yEndPosition;
191
    }
192
193
    /**
194
     * Get the region's width.
195
     *
196
     * @access public
197
     *
198
     * @return int The region's width
199
     */
200
    public function getWidth()
201
    {
202
        return $this->width;
203
    }
204
205
    /**
206
     * Get the region's height.
207
     *
208
     * @access public
209
     *
210
     * @return int The region's height
211
     */
212
    public function getHeight()
213
    {
214
        return $this->height;
215
    }
216
217
    /**
218
     * Get the region's text.
219
     *
220
     * @access public
221
     *
222
     * @return string The region's text
223
     */
224
    public function getText()
225
    {
226
        return $this->text;
227
    }
228
}
229