Completed
Push — master ( 616b03...431b60 )
by Marko
10s
created

VisibleComponent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 59
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeComponent() 0 6 1
A set() 0 5 2
A hasDOMAttributes() 0 4 1
A getDomAttributeString() 0 4 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jul 7, 2016 - 1:31:44 AM
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         VisibleComponent.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\Visible;
25
26
use \AframeVR\Interfaces\Core\Components\VisibleCMPTIF;
27
use \AframeVR\Core\Helpers\ComponentAbstract;
28
29
class VisibleComponent extends ComponentAbstract implements VisibleCMPTIF
30
{
31
    protected $dom_attribute;
32
    
33
    /**
34
     * Initialize Component
35
     *
36
     * {@inheritdoc}
37
     *
38
     * @return bool
39
     */
40 2
    public function initializeComponent(): bool
41
    {
42 2
        $this->setDomAttribute('visible');
43 2
        $this->set();
44 2
        return true;
45
    }
46
47
    /**
48
     * Entity visible
49
     *
50
     * {@inheritdoc}
51
     *
52
     * @param bool $visible
53
     * @return VisibleCMPTIF
54
     */
55 2
    public function set(bool $visible = true): VisibleCMPTIF
56
    {
57 2
        $this->dom_attribute = $visible ? 'true' : 'false';
58 2
        return $this;
59
    }
60
    
61
    /**
62
     * Does component have DOM Atributes
63
     * 
64
     * If compnent is called then we return true
65
     * 
66
     * {@inheritdoc}
67
     *
68
     * @return bool
69
     */
70 1
    public function hasDOMAttributes(): bool
71
    {
72 1
        return true;
73
    }
74
    
75
    /**
76
     * Return DOM attribute contents
77
     *
78
     * Scale Components dom atribute contains roll, pitch, yaw
79
     * Ex: rotation="1 1 1"
80
     *
81
     * @return string
82
     */
83 1
    public function getDomAttributeString(): string
84
    {
85 1
        return $this->dom_attribute;
86
    }
87
}