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

Flat::height()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 1
b 1
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jun 21, 2016 - 2:19:19 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         Flat.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 Flat implements ShaderInterface
29
{
30
31
    /**
32
     * Base diffuse color.
33
     *
34
     * @var string $color
35
     */
36
    public $color = '#fff';
37
38
    /**
39
     * Whether or not material is affected by fog.
40
     *
41
     * @var string $fog
42
     */
43
    public $fog = 'true';
44
45
    /**
46
     * Height of video (in pixels), if defining a video texture.
47
     *
48
     * @var int $height
49
     */
50
    public $height = 360;
51
52
    /**
53
     * How many times a texture (defined by src) repeats in the X and Y direction.
54
     *
55
     * @var string $repeat
56
     */
57
    public $repeat = '1 1';
58
59
    /**
60
     * Image or video texture map.
61
     * Can either be a selector to an <img> or <video>, or an inline URL.
62
     *
63
     * @var string|null $src
64
     */
65
    public $src = null;
66
67
    /**
68
     * Width of video (in pixels), if defining a video texture.
69
     *
70
     * @var int $width
71
     */
72
    public $width = 640;
73
74
    /**
75
     * removeDefaultDOMAttributes
76
     *
77
     * @return void
78
     */
79 1 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...
80
    {
81 1
        $defaults = get_class_vars(get_class($this));
82 1
        foreach (get_object_vars($this) as $name => $value) {
83 1
            if (empty($value) || (array_key_exists($name, $defaults) && $value === $defaults[$name]))
84 1
                unset($this->$name);
85
        }
86 1
    }
87
88
    /**
89
     * Base diffuse color
90
     *
91
     * @param string $color            
92
     */
93 1
    public function color(string $color = '#fff')
94
    {
95 1
        $this->color = $color;
96 1
    }
97
98
    /**
99
     * Whether or not material is affected by fog.
100
     *
101
     * @param bool $fog            
102
     */
103 1
    public function fog(bool $fog = true)
104
    {
105 1
        $this->fog = $fog ? 'true' : 'false';
106 1
    }
107
108
    /**
109
     * Height of video (in pixels), if defining a video texture.
110
     *
111
     * @param int $height            
112
     */
113 1
    public function height(int $height = 360)
114
    {
115 1
        $this->height = $height;
116 1
    }
117
118
    /**
119
     *
120
     * @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...
121
     * @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...
122
     */
123 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...
124
    {
125 1
        $this->repeat = sprintf('%d %d', $x, $y);
126 1
    }
127
128
    /**
129
     * How many times a texture (defined by src) repeats in the X and Y direction.
130
     *
131
     * @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...
132
     */
133 1
    public function src(string $src = null)
134
    {
135 1
        $this->src = $src;
136 1
    }
137
138
    /**
139
     * Width of video (in pixels), if defining a video texture.
140
     *
141
     * @param int $width            
142
     */
143 1
    public function width(int $width = 360)
144
    {
145 1
        $this->width = $width;
146 1
    }
147
}
148