Completed
Push — master ( 94f348...ce557b )
by Marko
02:44
created

Standard   B

Complexity

Total Complexity 14

Size/Duplication

Total Lines 109
Duplicated Lines 7.34 %

Coupling/Cohesion

Components 9
Dependencies 0

Test Coverage

Coverage 36.36%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 14
lcom 9
cbo 0
dl 8
loc 109
ccs 12
cts 33
cp 0.3636
rs 7.1428
c 1
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
B removeDefaultDOMAttributes() 8 8 5
A height() 0 4 1
A envMap() 0 4 1
A fog() 0 4 1
A repeat() 0 4 1
A width() 0 4 1
A color() 0 4 1
A metalness() 0 4 1
A roughness() 0 4 1
A src() 0 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 21, 2016 - 1:53:21 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         Standard.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\Shaders;
25
26
use \AframeVR\Interfaces\ShaderInterface;
27
28
class Standard implements ShaderInterface
29
{
30
31
    /**
32
     * Base diffuse color.
33
     */
34
    public $color = '#fff';
35
36
    /**
37
     * Height of video (in pixels), if defining a video texture.
38
     *
39
     * @var unknown
40
     */
41
    public $height = '360';
42
43
    /**
44
     * Environment cubemap texture for reflections.
45
     *
46
     * Can be a selector to or a comma-separated list of URLs.
47
     */
48
    public $envMap = false;
49
50
    /**
51
     * Whether or not material is affected by fog.
52
     */
53
    public $fog = true;
54
55
    /**
56
     * How metallic the material is from 0 to 1.
57
     */
58
    public $metalness = '0.5';
59
60
    /**
61
     * How many times a texture (defined by src) repeats in the X and Y direction.
62
     */
63
    public $repeat = '1 1';
64
65
    /**
66
     * How rough the material is from 0 to 1.
67
     * A rougher material will scatter
68
     * reflected light in more directions than a smooth material.
69
     */
70
    public $roughness = '0.5';
71
72
    /**
73
     * Width of video (in pixels), if defining a video texture.
74
     */
75
    public $width = '640';
76
77
    /**
78
     * Image or video texture map.
79
     * Can either be a selector to an <img> or <video>, or an inline URL.
80
     */
81
    public $src = null;
82
83 View Code Duplication
    public function removeDefaultDOMAttributes()
0 ignored issues
show
Duplication introduced by
This method 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...
84
    {
85
        $defaults = get_class_vars(get_class($this));
86
        foreach (get_object_vars($this) as $name => $value) {
87
            if (empty($value) || (array_key_exists($name, $defaults) && $value === $defaults[$name]))
88
                unset($this->$name);
89
        }
90
    }
91
92 3
    public function color(string $color = '#fff')
93
    {
94 3
        $this->color = $color;
95 3
    }
96
97
    public function height(string $height = '360')
98
    {
99
        $this->height = $height;
0 ignored issues
show
Documentation Bug introduced by
It seems like $height of type string is incompatible with the declared type object<AframeVR\Core\Shaders\unknown> of property $height.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
100
    }
101
102
    public function envMap($envMap = false)
103
    {
104
        $this->envMap = $envMap;
105
    }
106
107
    public function fog(bool $fog = true)
108
    {
109
        $this->fog = $fog;
110
    }
111
112 3
    public function metalness(string $metalness = '0.5')
113
    {
114 3
        $this->metalness = $metalness;
115 3
    }
116
117
    public function repeat(string $repeat = '1 1')
118
    {
119
        $this->repeat = $repeat;
120
    }
121
122 3
    public function roughness(string $roughness = '0.5')
123
    {
124 3
        $this->roughness = $roughness;
125 3
    }
126
127
    public function width($width = '640')
128
    {
129
        $this->width = $width;
130
    }
131
132 3
    public function src(string $src = null)
133
    {
134 3
        $this->src = $src;
135 3
    }
136
}
137