Passed
Pull Request — master (#123)
by
unknown
07:06 queued 02:32
created

Region   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 186
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
c 0
b 0
f 0
dl 0
loc 186
rs 10
wmc 10

10 Methods

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