Completed
Push — master ( 610f9f...30d47a )
by Marko
03:48
created

ScaleComponent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 40
loc 40
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeComponent() 5 5 1
A getDomAttributeString() 5 5 1
A getScale() 4 4 1

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 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         ScaleComponent.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\Scale;
25
26
use \AframeVR\Interfaces\Core\Components\Scale\ScaleInterface;
27
use \AframeVR\Core\Helpers\ComponentAbstract;
28
use \AframeVR\Core\Helpers\ComponentHelper;
29
30
/**
31
 * AframeVR\Core\Components\Scale
32
 *
33
 * The scale component defines a shrinking, stretching, or skewing transformation of an entity.
34
 * It takes three scaling factors for the X, Y, and Z axes.
35
 */
36 View Code Duplication
class ScaleComponent extends ComponentAbstract implements ScaleInterface
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...
37
{
38
    use ComponentHelper;
39
40
    /**
41
     * Initialize Component
42
     *
43
     * {@inheritdoc}
44
     *
45
     * @return bool
46
     */
47 58
    public function initializeComponent(): bool
48
    {
49 58
        $this->setDomAttributeName('scale');
50 58
        return true;
51
    }
52
53
    /**
54
     * Return DOM attribute contents
55
     *
56
     * @return string
57
     */
58 4
    public function getDomAttributeString(): string
59
    {
60 4
        $attrs = $this->getDOMAttributesArray();
61 4
        return $this->createCoordinateString($attrs['x'], $attrs['y'], $attrs['z']);
62
    }
63
64
    /**
65
     * Get scale
66
     *
67
     * {@inheritdoc}
68
     *
69
     * @return string
70
     */
71 1
    public function getScale(): string
72
    {
73 1
        return $this->getDomAttributeString();
74
    }
75
}
76