Completed
Pull Request — master (#270)
by
unknown
03:25
created

AbstractUiElement::setSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
namespace eXpansion\Framework\Gui\Components;
4
5
use FML\Script\Features\ScriptFeature;
6
use FML\Types\Renderable;
7
8
abstract class AbstractUiElement extends ScriptFeature implements Renderable
9
{
10
    protected $_classes = [];
11
    protected $_dataAttributes = [];
12
    /**
13
     * @var int
14
     */
15
    protected $posX = 0;
16
    /**
17
     * @var int
18
     */
19
    protected $posY = 0;
20
    /**
21
     * @var int
22
     */
23
    protected $posZ = 0;
24
25
    /**
26
     * @var int
27
     */
28
    protected $width = 1;
29
    /**
30
     * @var int
31
     */
32
    protected $height = 1;
33
    /**
34
     * @var string
35
     */
36
    protected $horizontalAlign = "left";
37
    /**
38
     * @var string
39
     */
40
    protected $verticalAlign = "top";
41
42
    /**
43
     * @param int $posX
44
     * @param int $posY
45
     * @param int $posZ
46
     * @return AbstractUiElement
47
     */
48
    public function setPosition($posX = 0, $posY = 0, $posZ = 0)
49
    {
50
        $this->posX = $posX;
51
        $this->posY = $posY;
52
        $this->posZ = $posZ;
53
54
        return $this;
55
56
    }
57
58
    /**
59
     * @param $X
60
     * @return $this
61
     */
62
    public function setX($X)
63
    {
64
        $this->posX = $X;
65
66
        return $this;
67
    }
68
69
    /**
70
     * @param $Y
71
     * @return $this
72
     */
73
    public function setY($Y)
74
    {
75
        $this->posY = $Y;
76
77
        return $this;
78
    }
79
80
    /**
81
     * @param $Z
82
     * @return $this
83
     */
84
    public function setZ($Z)
85
    {
86
        $this->posZ = $Z;
87
88
        return $this;
89
    }
90
91
    /**
92
     * Render the XML element
93
     *
94
     * @param \DOMDocument $domDocument DOMDocument for which the XML element should be rendered
95
     * @return \DOMElement
96
     */
97
    abstract public function render(\DOMDocument $domDocument);
98
99
    /**
100
     * @return int
101
     */
102
    public function getX()
103
    {
104
        return $this->posX;
105
    }
106
107
    /**
108
     * @return int
109
     */
110
    public function getY()
111
    {
112
        return $this->posY;
113
    }
114
115
    /**
116
     * @return int
117
     */
118
    public function getZ()
119
    {
120
        return $this->posZ;
121
    }
122
123
    /**
124
     * @return mixed
125
     */
126
    public function getWidth()
127
    {
128
        return $this->width;
129
    }
130
131
    /**
132
     * @param mixed $width
133
     * @return static
134
     */
135
    public function setWidth($width)
136
    {
137
        $this->width = $width;
138
139
        return $this;
140
    }
141
142
    /**
143
     * @param mixed $height
144
     * @return static
145
     */
146
    public function setHeight($height)
147
    {
148
        $this->height = $height;
149
150
        return $this;
151
    }
152
153
    /**
154
     * @return mixed
155
     */
156
    public function getHeight()
157
    {
158
        return $this->height;
159
    }
160
161
    /**
162
     * @param $x
163
     * @param $y
164
     * @return $this
165
     */
166
    public function setSize($x, $y)
167
    {
168
        $this->width = $x;
169
        $this->height = $y;
170
171
        return $this;
172
    }
173
174
    /**
175
     * @param $name
176
     * @param $value
177
     * @return $this
178
     */
179
    public function addDataAttribute($name, $value)
180
    {
181
        $this->_dataAttributes[$name] = $value;
182
183
        return $this;
184
    }
185
186
    /**
187
     * @param $name
188
     * @return $this
189
     */
190
    public function addClass($name)
191
    {
192
        $this->_classes[] = $name;
193
194
        return $this;
195
    }
196
197
    /**
198
     * @return string
199
     */
200
    public function getHorizontalAlign(): string
201
    {
202
        return $this->horizontalAlign;
203
    }
204
205
    /**
206
     * @param string $horizontalAlign
207
     * @return static
208
     */
209
    public function setHorizontalAlign(string $horizontalAlign)
210
    {
211
        $this->horizontalAlign = $horizontalAlign;
212
213
        return $this;
214
    }
215
216
    /**
217
     * @return string
218
     */
219
    public function getVerticalAlign(): string
220
    {
221
        return $this->verticalAlign;
222
    }
223
224
    /**
225
     * @param string $verticalAlign
226
     * @return static
227
     */
228
    public function setVerticalAlign(string $verticalAlign)
229
    {
230
        $this->verticalAlign = $verticalAlign;
231
232
        return $this;
233
    }
234
235
}
236