Passed
Pull Request — master (#86)
by
unknown
02:39
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 constructor for highlight.
76
     *
77
     * @access public
78
     *
79
     * @param array $highlight: Array of found highlight properties
80
     *
81
     * @return void
82
     */
83
    public function __construct($highlight)
84
    {
85
        $this->parentRegionId = $highlight['parentRegionIdx'];
86
        $this->xBeginPosition = $highlight['ulx'];
87
        $this->xEndPosition = $highlight['lrx'];
88
        $this->yBeginPosition = $highlight['uly'];
89
        $this->yEndPosition = $highlight['lry'];
90
        $this->id = $this->xBeginPosition . '_' . $this->yBeginPosition;
91
    }
92
93
    /**
94
     * Get the highlight's identifier.
95
     *
96
     * @access public
97
     *
98
     * @return string The highlight's identifier
99
     */
100
    public function getId()
101
    {
102
        return $this->id;
103
    }
104
105
    /**
106
     * Get the highlight's horizontal beginning position.
107
     *
108
     * @access public
109
     *
110
     * @return int The highlight's horizontal beginning position
111
     */
112
    public function getXBeginPosition()
113
    {
114
        return $this->xBeginPosition;
115
    }
116
117
    /**
118
     * Get the highlight's horizontal ending position.
119
     *
120
     * @access public
121
     *
122
     * @return int The highlight's horizontal ending position
123
     */
124
    public function getXEndPosition()
125
    {
126
        return $this->xEndPosition;
127
    }
128
129
    /**
130
     * Get the highlight's vertical beginning position.
131
     *
132
     * @access public
133
     *
134
     * @return int The highlight's vertical beginning position
135
     */
136
    public function getYBeginPosition()
137
    {
138
        return $this->yBeginPosition;
139
    }
140
141
    /**
142
     * Get the highlight's vertical ending position.
143
     *
144
     * @access public
145
     *
146
     * @return int The highlight's vertical ending position
147
     */
148
    public function getYEndPosition()
149
    {
150
        return $this->yEndPosition;
151
    }
152
}
153