Completed
Push — 0.3.x ( 4f6fde...8ea901 )
by Marko
02:33
created

DefaultMethods   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 1
Metric Value
wmc 4
c 4
b 1
f 1
lcom 1
cbo 0
dl 54
loc 54
ccs 17
cts 17
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 6 6 1
A roll() 5 5 1
A pitch() 5 5 1
A yaw() 5 5 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 27, 2016 - 2:54:40 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         DefaultMethods.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\Rotation\Methods;
25
26 View Code Duplication
class DefaultMethods
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...
27
{
28
    /**
29
     * When any rotation component methods are called then init others
30
     *
31
     * @param array $dom_attributes
32
     * @return void
33
     */
34 15
    private function init(array &$dom_attributes)
35
    {
36 15
        $dom_attributes['x'] = $dom_attributes['x'] ?? 0;
37 15
        $dom_attributes['y'] = $dom_attributes['y'] ?? 0;
38 15
        $dom_attributes['z'] = $dom_attributes['z'] ?? 0;
39 15
    }
40
    
41
    /**
42
     * Roll, rotation about the X-axis.
43
     *
44
     * @param array $dom_attributes            
45
     * @param double $roll            
46
     * @return void
47
     */
48 15
    public function roll(array &$dom_attributes, float $roll)
49
    {
50 15
        $this->init($dom_attributes);
51 15
        $dom_attributes['x'] = $roll;
52 15
    }
53
54
    /**
55
     * Pitch, rotation about the Y-axis.
56
     *
57
     * @param array $dom_attributes            
58
     * @param double $pitch            
59
     * @return void
60
     */
61 14
    public function pitch(array &$dom_attributes, float $pitch)
62
    {
63 14
        $this->init($dom_attributes);
64 14
        $dom_attributes['y'] = $pitch;
65 14
    }
66
67
    /**
68
     * Yaw, rotation about the Z-axis.
69
     *
70
     * @param array $dom_attributes            
71
     * @param double $yaw            
72
     * @return void
73
     */
74 14
    public function yaw(array &$dom_attributes, float $yaw)
75
    {
76 14
        $this->init($dom_attributes);
77 14
        $dom_attributes['z'] = $yaw;
78 14
    }
79
}
80