Completed
Push — master ( f0770d...00a9a3 )
by Marko
02:14
created

Standard::removeDefaultDOMAttributes()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 3
Bugs 2 Features 0
Metric Value
dl 8
loc 8
ccs 6
cts 6
cp 1
rs 9.2
c 3
b 2
f 0
cc 4
eloc 5
nc 3
nop 0
crap 4
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
use \AframeVR\Core\Helpers\ShaderAbstract;
28
29
class Standard extends ShaderAbstract implements ShaderInterface
30
{
31
32
    /**
33
     * Base diffuse color.
34
     *
35
     * @var string $color
36
     */
37
    public $color = '#fff';
38
39
    /**
40
     * Height of video (in pixels), if defining a video texture.
41
     *
42
     * @var int $height
43
     */
44
    public $height = 360;
45
46
    /**
47
     * Environment cubemap texture for reflections.
48
     *
49
     * Can be a selector to or a comma-separated list of URLs.
50
     *
51
     * @var string|null $envMap
52
     */
53
    public $envMap = null;
54
55
    /**
56
     * Whether or not material is affected by fog.
57
     *
58
     * @var string $fog
59
     */
60
    public $fog = 'true';
61
62
    /**
63
     * How metallic the material is from 0 to 1.
64
     *
65
     * @var float $metalness
66
     */
67
    public $metalness = 0.5;
68
69
    /**
70
     * How many times a texture (defined by src) repeats in the X and Y direction.
71
     *
72
     * @var string $repeat
73
     */
74
    public $repeat = '1 1';
75
76
    /**
77
     * How rough the material is from 0 to 1.
78
     * A rougher material will scatter
79
     * reflected light in more directions than a smooth material.
80
     *
81
     * @var float $roughness
82
     */
83
    public $roughness = 0.5;
84
85
    /**
86
     * Image or video texture map.
87
     * Can either be a selector to an <img> or <video>, or an inline URL.
88
     *
89
     * @var string|null $src
90
     */
91
    public $src = null;
92
93
    /**
94
     * Width of video (in pixels), if defining a video texture.
95
     *
96
     * @var int $width
97
     */
98
    public $width = 640;
99
100
    /**
101
     * Base diffuse color
102
     *
103
     * @param string $color            
104
     */
105 9
    public function color(string $color = '#fff')
106
    {
107 9
        $this->color = $color;
108 9
    }
109
110
    /**
111
     * Height of video (in pixels), if defining a video texture.
112
     *
113
     * @param int $height            
114
     */
115 1
    public function height(int $height = 360)
116
    {
117 1
        $this->height = $height;
118 1
    }
119
120
    /**
121
     * envMap
122
     *
123
     * Environment cubemap texture for reflections.
124
     * Can be a selector to or a comma-separated list of URLs.
125
     *
126
     * @param string|null $envMap            
127
     */
128 1
    public function envMap(string $envMap = null)
129
    {
130 1
        $this->envMap = $envMap;
131 1
    }
132
133
    /**
134
     * Whether or not material is affected by fog.
135
     *
136
     * @param bool $fog            
137
     */
138 1
    public function fog(bool $fog = true)
139
    {
140 1
        $this->fog = $fog ? 'true' : 'false';
141 1
    }
142
143
    /**
144
     * How metallic the material is from 0 to 1.
145
     *
146
     * @param float $metalness            
147
     */
148 6
    public function metalness(float $metalness = 0.5)
149
    {
150 6
        $this->metalness = $metalness;
151 6
    }
152
153
    /**
154
     * repeat
155
     *
156
     * @param int|float $x            
157
     * @param int|float $y            
158
     */
159 1
    public function repeat(float $x = 1, float $y = 1)
160
    {
161 1
        $this->repeat = sprintf('%d %d', $x, $y);
162 1
    }
163
164
    /**
165
     * How rough the material is from 0 to 1
166
     *
167
     * A rougher material will scatter reflected light in more directions than a smooth material.
168
     *
169
     * @param float $roughness            
170
     */
171 6
    public function roughness(float $roughness = 0.5)
172
    {
173 6
        $this->roughness = $roughness;
174 6
    }
175
176
    /**
177
     * How many times a texture (defined by src) repeats in the X and Y direction.
178
     *
179
     * @param string|null $src            
180
     */
181 7
    public function src(string $src = null)
182
    {
183 7
        $this->src = $src;
184 7
    }
185
186
    /**
187
     * Width of video (in pixels), if defining a video texture.
188
     *
189
     * @param int $width            
190
     */
191 1
    public function width(int $width = 360)
192
    {
193 1
        $this->width = $width;
194 1
    }
195
    
196
    /**
197
     * removeDefaultDOMAttributes
198
     *
199
     * @return void
200
     */
201 3 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...
202
    {
203 3
        $defaults = $this->getShaderClassDefaultVars();
204 3
        foreach ($this as $name => $value) {
0 ignored issues
show
Bug introduced by
The expression $this of type this<AframeVR\Core\Shaders\Standard> is not traversable.
Loading history...
205 3
            if (empty($value) || $value === $defaults[$name])
206 3
                unset($this->$name);
207
        }
208 3
    }
209
}
210