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

LookControlsComponent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 45
loc 45
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasDOMAttributes() 4 4 1
A initializeComponent() 6 6 1
A enabled() 5 5 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jul 4, 2016 - 3:14:06 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         LookControlsComponent.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\LookControls;
25
26
use \AframeVR\Interfaces\Core\Components\LookControlsCMPTIF;
27
use \AframeVR\Core\Helpers\ComponentAbstract;
28
29 View Code Duplication
class LookControlsComponent extends ComponentAbstract implements LookControlsCMPTIF
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
{
31
32
    /**
33
     * Does component have DOM Atributes
34
     *
35
     * If compnent is called then we return true
36
     *
37
     * {@inheritdoc}
38
     *
39
     * @return bool
40
     */
41 2
    public function hasDOMAttributes(): bool
42
    {
43 2
        return true;
44
    }
45
46
    /**
47
     * Initialize Component
48
     *
49
     * {@inheritdoc}
50
     *
51
     * @return bool
52
     */
53 7
    public function initializeComponent(): bool
54
    {
55 7
        $this->setDomAttribute('look-controls');
56 7
        $this->enabled();
57 7
        return true;
58
    }
59
60
    /**
61
     * look-controls enabled
62
     *
63
     * {@inheritdoc}
64
     *
65
     * @param bool $enabled            
66
     * @return LookControlsCMPTIF
67
     */
68 7
    public function enabled(bool $enabled = true): LookControlsCMPTIF
69
    {
70 7
        $this->dom_attributes['enabled'] = $enabled ? 'true' : 'false';
71 7
        return $this;
72
    }
73
}
74