Completed
Push — master ( 95af13...697c38 )
by Marko
8s
created

WASDControlsComponent::enabled()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 2
eloc 2
nc 2
nop 1
crap 2
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jul 4, 2016 - 3:21:00 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         WASDControlsComponent.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\WASDControls;
25
26
use \AframeVR\Core\Helpers\ComponentAbstract;
27
28
class WASDControlsComponent extends ComponentAbstract
29
{
30
    /**
31
     * Initialize Component
32
     *
33
     * {@inheritdoc}
34
     *
35
     * @return bool
36
     */
37 6
    public function initializeComponent(): bool
38
    {
39 6
        $this->setDomAttribute('wasd-controls');
40 6
        return true;
41
    }
42
    
43
    /**
44
     * wasd-controls enabled
45
     *
46
     * Whether the WASD controls are enabled.
47
     *
48
     * @param bool $enabled
49
     * @return void
50
     */
51 6
    public function enabled(bool $enabled = true)
52
    {
53 6
        $this->dom_attributes['enabled'] = $enabled ? 'true' : 'false';
54 6
    }
55
}
56