Completed
Push — master ( 5f3088...bfb206 )
by Marko
02:40
created

Standard::fog()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 2
b 1
f 0
cc 2
eloc 2
nc 2
nop 1
crap 2
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
     * @var string $color
35
     */
36
    public $color = '#fff';
37
38
    /**
39
     * Height of video (in pixels), if defining a video texture.
40
     *
41
     * @var int $height
42
     */
43
    public $height = 360;
44
45
    /**
46
     * Environment cubemap texture for reflections.
47
     *
48
     * Can be a selector to or a comma-separated list of URLs.
49
     *
50
     * @var string|null $envMap
51
     */
52
    public $envMap = null;
53
54
    /**
55
     * Whether or not material is affected by fog.
56
     *
57
     * @var string $fog
58
     */
59
    public $fog = 'true';
60
61
    /**
62
     * How metallic the material is from 0 to 1.
63
     *
64
     * @var float $metalness
65
     */
66
    public $metalness = 0.5;
67
68
    /**
69
     * How many times a texture (defined by src) repeats in the X and Y direction.
70
     *
71
     * @var string $repeat
72
     */
73
    public $repeat = '1 1';
74
75
    /**
76
     * How rough the material is from 0 to 1.
77
     * A rougher material will scatter
78
     * reflected light in more directions than a smooth material.
79
     *
80
     * @var float $roughness
81
     */
82
    public $roughness = 0.5;
83
84
    /**
85
     * Image or video texture map.
86
     * Can either be a selector to an <img> or <video>, or an inline URL.
87
     *
88
     * @var string|null $src
89
     */
90
    public $src = null;
91
92
    /**
93
     * Width of video (in pixels), if defining a video texture.
94
     *
95
     * @var int $width
96
     */
97
    public $width = 640;
98
99
    /**
100
     * Remove default attributes
101
     *
102
     * @return void
103
     */
104 2 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...
105
    {
106 2
        $defaults = get_class_vars(get_class($this));
107 2
        foreach (get_object_vars($this) as $name => $value) {
108 2
            if (empty($value) || (array_key_exists($name, $defaults) && $value === $defaults[$name]))
109 2
                unset($this->$name);
110
        }
111 2
    }
112
113
    /**
114
     * Base diffuse color
115
     *
116
     * @param string $color            
117
     */
118 8
    public function color(string $color = '#fff')
119
    {
120 8
        $this->color = $color;
121 8
    }
122
123
    /**
124
     * Height of video (in pixels), if defining a video texture.
125
     *
126
     * @param int $height            
127
     */
128 1
    public function height(int $height = 360)
129
    {
130 1
        $this->height = $height;
131 1
    }
132
133
    /**
134
     * envMap
135
     *
136
     * Environment cubemap texture for reflections.
137
     * Can be a selector to or a comma-separated list of URLs.
138
     *
139
     * @param string $envMap            
0 ignored issues
show
Documentation introduced by
Should the type for parameter $envMap not be null|string?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
140
     */
141 1
    public function envMap(string $envMap = null)
142
    {
143 1
        $this->envMap = $envMap;
144 1
    }
145
146
    /**
147
     * Whether or not material is affected by fog.
148
     *
149
     * @param bool $fog            
150
     */
151 1
    public function fog(bool $fog = true)
152
    {
153 1
        $this->fog = $fog ? 'true' : 'false';
154 1
    }
155
156
    /**
157
     * How metallic the material is from 0 to 1.
158
     *
159
     * @param float $metalness            
160
     */
161 6
    public function metalness(float $metalness = 0.5)
162
    {
163 6
        $this->metalness = $metalness;
164 6
    }
165
166
    /**
167
     * repeat
168
     *
169
     * @param float $x            
0 ignored issues
show
Documentation introduced by
Should the type for parameter $x not be integer|double?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
170
     * @param float $y            
0 ignored issues
show
Documentation introduced by
Should the type for parameter $y not be integer|double?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
171
     */
172 1
    public function repeat(float $x = 1, float $y = 1)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $x. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
Comprehensibility introduced by
Avoid variables with short names like $y. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
173
    {
174 1
        $this->repeat = sprintf('%d %d', $x, $y);
175 1
    }
176
177
    /**
178
     * How rough the material is from 0 to 1
179
     *
180
     * A rougher material will scatter reflected light in more directions than a smooth material.
181
     *
182
     * @param float $roughness            
183
     */
184 6
    public function roughness(float $roughness = 0.5)
185
    {
186 6
        $this->roughness = $roughness;
187 6
    }
188
189
    /**
190
     * How many times a texture (defined by src) repeats in the X and Y direction.
191
     *
192
     * @param string $src            
0 ignored issues
show
Documentation introduced by
Should the type for parameter $src not be null|string?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
193
     */
194 7
    public function src(string $src = null)
195
    {
196 7
        $this->src = $src;
197 7
    }
198
199
    /**
200
     * Width of video (in pixels), if defining a video texture.
201
     *
202
     * @param int $width            
203
     */
204 1
    public function width(int $width = 360)
205
    {
206 1
        $this->width = $width;
207 1
    }
208
}
209