Code Duplication    Length = 97-97 lines in 3 locations

src/Components/Position.php 1 location

@@ 34-130 (lines=97) @@
31
 *
32
 * All entities inherently have the position component.
33
 */
34
class Position implements ComponentInterface
35
{
36
37
    /**
38
     * Negative X axis extends left.
39
     * Positive X Axis extends right.
40
     * 
41
     * @var int $x
42
     */
43
    protected $x;
44
45
    /**
46
     * Negative Y axis extends up.
47
     * Positive Y Axis extends down.
48
     * 
49
     * @var int $y
50
     */
51
    protected $y;
52
53
    /**
54
     * Negative Z axis extends in.
55
     * Positive Z Axis extends out.
56
     * 
57
     * @var int $z
58
     */
59
    protected $z;
60
61
    /**
62
     * Set initial coordinates
63
     *
64
     * @param string $coordinates            
65
     */
66
    public function __construct($x = 0, $y = 0, $z = 0)
67
    {
68
        $this->update($x, $y, $z);
69
    }
70
71
    /**
72
     * Get Component scripts
73
     *
74
     * {@inheritdoc}
75
     *
76
     * @return array
77
     */
78
    public function getScripts(): array
79
    {
80
        return array();
81
    }
82
83
    /**
84
     * Does component have DOM Atributes
85
     *
86
     * {@inheritdoc}
87
     *
88
     * @return bool
89
     */
90
    public function hasDOMAttributes(): bool
91
    {
92
        return ! empty(get_object_vars($this));
93
    }
94
95
    /**
96
     * Remove default DOMElement Attributes which are not required
97
     *
98
     * @return void
99
     */
100
    public function removeDefaultDOMAttributes()
101
    {
102
        if ($this->x === 0 && $this->y === 0 && $this->z === 0) {
103
            unset($this->x);
104
            unset($this->y);
105
            unset($this->z);
106
        }
107
    }
108
109
    /**
110
     * Get DOMAttr for the entity
111
     *
112
     * @return DOMAttr
113
     */
114
    public function getDOMAttributes(): \DOMAttr
115
    {
116
        return new \DOMAttr('position', sprintf('%s %s %s', $this->x, $this->y, $this->z));
117
    }
118
119
    /**
120
     * Update coordinates
121
     *
122
     * @param string $coordinates            
123
     */
124
    public function update($x = 0, $y = 0, $z = 0)
125
    {
126
        $this->x = $x ?? 0;
127
        $this->y = $y ?? 0;
128
        $this->z = $z ?? 0;
129
    }
130
}

src/Components/Rotation.php 1 location

@@ 35-131 (lines=97) @@
32
 *
33
 * All entities inherently have the rotation component.
34
 */
35
class Rotation implements ComponentInterface
36
{
37
38
    /**
39
     * Negative X axis extends left.
40
     * Positive X Axis extends right.
41
     *
42
     * @var int $x
43
     */
44
    protected $x;
45
46
    /**
47
     * Negative Y axis extends up.
48
     * Positive Y Axis extends down.
49
     *
50
     * @var int $y
51
     */
52
    protected $y;
53
54
    /**
55
     * Negative Z axis extends in.
56
     * Positive Z Axis extends out.
57
     *
58
     * @var int $z
59
     */
60
    protected $z;
61
62
    /**
63
     * Set initial coordinates
64
     *
65
     * @param string $coordinates            
66
     */
67
    public function __construct($x = 0, $y = 0, $z = 0)
68
    {
69
        $this->update($x, $y, $z);
70
    }
71
72
    /**
73
     * Get Component scripts
74
     *
75
     * {@inheritdoc}
76
     *
77
     * @return array
78
     */
79
    public function getScripts(): array
80
    {
81
        return array();
82
    }
83
84
    /**
85
     * Does component have DOM Atributes
86
     *
87
     * {@inheritdoc}
88
     *
89
     * @return bool
90
     */
91
    public function hasDOMAttributes(): bool
92
    {
93
        return ! empty(get_object_vars($this));
94
    }
95
96
    /**
97
     * Remove default DOMElement Attributes which are not required
98
     *
99
     * @return void
100
     */
101
    public function removeDefaultDOMAttributes()
102
    {
103
        if ($this->x === 0 && $this->y === 0 && $this->z === 0) {
104
            unset($this->x);
105
            unset($this->y);
106
            unset($this->z);
107
        }
108
    }
109
110
    /**
111
     * Get DOMAttr for the entity
112
     *
113
     * @return DOMAttr
114
     */
115
    public function getDOMAttributes(): \DOMAttr
116
    {
117
        return new \DOMAttr('rotation', sprintf('%s %s %s', $this->x, $this->y, $this->z));
118
    }
119
120
    /**
121
     * Update coordinates
122
     *
123
     * @param string $coordinates            
124
     */
125
    public function update($x = 0, $y = 0, $z = 0)
126
    {
127
        $this->x = $x ?? 0;
128
        $this->y = $y ?? 0;
129
        $this->z = $z ?? 0;
130
    }
131
}
132

src/Components/Scale.php 1 location

@@ 34-130 (lines=97) @@
31
 *
32
 * All entities inherently have the rotation component.
33
 */
34
class Scale implements ComponentInterface
35
{
36
37
    /**
38
     * Negative X axis extends left.
39
     * Positive X Axis extends right.
40
     *
41
     * @var int $x
42
     */
43
    protected $x;
44
45
    /**
46
     * Negative Y axis extends up.
47
     * Positive Y Axis extends down.
48
     *
49
     * @var int $y
50
     */
51
    protected $y;
52
53
    /**
54
     * Negative Z axis extends in.
55
     * Positive Z Axis extends out.
56
     *
57
     * @var int $z
58
     */
59
    protected $z;
60
61
    /**
62
     * Set initial coordinates
63
     *
64
     * @param string $coordinates
65
     */
66
    public function __construct($x = 0, $y = 0, $z = 0)
67
    {
68
        $this->update($x, $y, $z);
69
    }
70
71
    /**
72
     * Get Component scripts
73
     *
74
     * {@inheritdoc}
75
     *
76
     * @return array
77
     */
78
    public function getScripts(): array
79
    {
80
        return array();
81
    }
82
83
    /**
84
     * Does component have DOM Atributes
85
     *
86
     * {@inheritdoc}
87
     *
88
     * @return bool
89
     */
90
    public function hasDOMAttributes(): bool
91
    {
92
        return ! empty(get_object_vars($this));
93
    }
94
95
    /**
96
     * Remove default DOMElement Attributes which are not required
97
     *
98
     * @return void
99
     */
100
    public function removeDefaultDOMAttributes()
101
    {
102
        if ($this->x === 0 && $this->y === 0 && $this->z === 0) {
103
            unset($this->x);
104
            unset($this->y);
105
            unset($this->z);
106
        }
107
    }
108
109
    /**
110
     * Get DOMAttr for the entity
111
     *
112
     * @return DOMAttr
113
     */
114
    public function getDOMAttributes(): \DOMAttr
115
    {
116
        return new \DOMAttr('scale', sprintf('%s %s %s', $this->x, $this->y, $this->z));
117
    }
118
119
    /**
120
     * Update coordinates
121
     *
122
     * @param string $coordinates
123
     */
124
    public function update($x = 0, $y = 0, $z = 0)
125
    {
126
        $this->x = $x ?? 0;
127
        $this->y = $y ?? 0;
128
        $this->z = $z ?? 0;
129
    }
130
}
131
132