Completed
Push — master ( 1f4a88...1e92cb )
by Marko
02:53
created

Component::getPosition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jun 25, 2016 - 7:51:42 PM
5
 * Contact      [email protected]
6
 * @copyright   2016 Marko Kungla - https://github.com/mkungla
7
 * @license     The MIT License (MIT)
8
 * 
9
 * @category       AframeVR
10
 * @package        aframe-php
11
 * 
12
 * Lang         PHP (php version >= 7)
13
 * Encoding     UTF-8
14
 * File         PositionComponent.php
15
 * Code format  PSR-2 and 12
16
 * @link        https://github.com/mkungla/aframe-php
17
 ^ @issues      https://github.com/mkungla/aframe-php/issues
18
 * ********************************************************************
19
 * Contributors:
20
 * @author Marko Kungla <[email protected]>
21
 * ********************************************************************
22
 * Comments:
23
 * @formatter:on */
24
namespace AframeVR\Core\Components\Position;
25
26
use \AframeVR\Interfaces\Core\Components\Position\PositionInterface;
27
use \AframeVR\Core\Helpers\ComponentAbstract;
28
use \AframeVR\Core\Helpers\ComponentHelper;
29
30
/**
31
 * AframeVR\Core\Components\Position
32
 *
33
 * The position component defines where an entity is placed in the scene's world space.
34
 * It takes a coordinate value as three space-delimited numbers.
35
 */
36
class Component extends ComponentAbstract implements PositionInterface
37
{
38
    use ComponentHelper;
39
40
    /**
41
     * Initialize Component
42
     *
43
     * {@inheritdoc}
44
     *
45
     * @return bool
46
     *
47
     */
48 56
    public function initializeComponent(): bool
49
    {
50 56
        $this->setDomAttributeName('position');
51 56
        return true;
52
    }
53
54
    /**
55
     * Return DOM attribute contents
56
     *
57
     * @return string
58
     */
59 4
    public function getDomAttributeString(): string
60
    {
61 4
        $attrs = $this->getDOMAttributesArray();
62 4
        return $this->createCoordinateString($attrs['x'], $attrs['y'], $attrs['z']);
63
    }
64
65
    /**
66
     * Get current position
67
     *
68
     * {@inheritdoc}
69
     *
70
     * @return string
71
     */
72 1
    public function getPosition(): string
73
    {
74 1
        return $this->getDomAttributeString();
75
    }
76
}
77