Completed
Pull Request — master (#95)
by
unknown
03:41
created

abstractUiElement::setSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 5
cp 0
cc 1
eloc 3
nc 1
nop 2
crap 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
    protected $posX = 0;
13
    protected $posY = 0;
14
    protected $posZ = 0;
15
16
    protected $width;
17
    protected $height;
18
19
    /**
20
     * @param int $posX
21
     * @param int $posY
22
     * @param int $posZ
23
     */
24
    public function setPosition($posX = 0, $posY = 0, $posZ = 0)
25
    {
26
        $this->posX = $posX;
27
        $this->posY = $posY;
28
        $this->posZ = $posZ;
29
30
        return $this;
31
32
    }
33
34
    public function setX($X)
35
    {
36
        $this->posX = $X;
37
38
        return $this;
39
    }
40
41
    public function setY($Y)
42
    {
43
        $this->posY = $Y;
44
45
        return $this;
46
    }
47
48
    public function setZ($Z)
49
    {
50
        $this->posZ = $Z;
51
52
        return $this;
53
    }
54
55
    /**
56
     * Render the XML element
57
     *
58
     * @param \DOMDocument $domDocument DOMDocument for which the XML element should be rendered
59
     * @return \DOMElement
60
     */
61
    abstract public function render(\DOMDocument $domDocument);
62
63
    /**
64
     * @return int
65
     */
66
    public function getX()
67
    {
68
        return $this->posX;
69
    }
70
71
    /**
72
     * @return int
73
     */
74
    public function getY()
75
    {
76
        return $this->posY;
77
    }
78
79
    /**
80
     * @return int
81
     */
82
    public function getZ()
83
    {
84
        return $this->posZ;
85
    }
86
87
    /**
88
     * @return mixed
89
     */
90
    public function getWidth()
91
    {
92
        return $this->width;
93
    }
94
95
    /**
96
     * @param mixed $width
97
     */
98
    public function setWidth($width)
99
    {
100
        $this->width = $width;
101
102
        return $this;
103
    }
104
105
    /**
106
     * @param mixed $height
107
     * @return abstractUiElement
108
     */
109
    public function setHeight($height)
110
    {
111
        $this->height = $height;
112
113
        return $this;
114
    }
115
116
    /**
117
     * @return mixed
118
     */
119
    public function getHeight()
120
    {
121
        return $this->height;
122
    }
123
124
    public function setSize($x, $y)
125
    {
126
        $this->width = $x;
127
        $this->height = $y;
128
    }
129
130
    public function addDataAttribute($name, $value)
131
    {
132
        $this->_dataAttributes[$name] = $value;
133
    }
134
135
    public function addClass($name)
136
    {
137
        $this->_classes[] = $name;
138
    }
139
140
}
141