Completed
Pull Request — master (#63)
by Marko
03:19
created

LightComponent   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 120
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 11.11%

Importance

Changes 0
Metric Value
wmc 9
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 120
ccs 3
cts 27
cp 0.1111
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeComponent() 0 5 1
A type() 0 5 1
A color() 0 5 1
A angle() 0 5 1
A decay() 0 5 1
A distance() 0 5 1
A exponent() 0 5 1
A groundColor() 0 5 1
A intensity() 0 5 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jul 6, 2016 - 9:12:58 PM
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         LightComponent.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\Light;
25
26
use \AframeVR\Interfaces\Core\Components\LightCMPTIF;
27
use \AframeVR\Core\Helpers\ComponentAbstract;
28
29
class LightComponent extends ComponentAbstract implements LightCMPTIF
30
{
31
32
    /**
33
     * Initialize Component
34
     *
35
     * {@inheritdoc}
36
     *
37
     * @return bool
38
     */
39 1
    public function initializeComponent(): bool
40
    {
41 1
        $this->setDomAttribute('light');
42 1
        return true;
43
    }
44
45
    /**
46
     * Light type
47
     *
48
     * One of ambient, directional, hemisphere, point, spot.
49
     *
50
     * @param string $type            
51
     * @return LightCMPTIF
52
     */
53
    public function type(string $type = 'directional'): LightCMPTIF
54
    {
55
        $this->dom_attributes['type'] = $type;
56
        return $this;
57
    }
58
59
    /**
60
     * Light color
61
     *
62
     * @param string $color            
63
     * @return LightCMPTIF
64
     */
65
    public function color(string $color = '#fff'): LightCMPTIF
66
    {
67
        $this->dom_attributes['color'] = $color;
68
        return $this;
69
    }
70
71
    /**
72
     * Light angle
73
     *
74
     * Maximum extent of spot light from its direction (in degrees).
75
     *
76
     * @param int|float $angle            
77
     * @return LightCMPTIF
78
     */
79
    public function angle(float $angle = 60): LightCMPTIF
80
    {
81
        $this->dom_attributes['angle'] = $angle;
82
        return $this;
83
    }
84
85
    /**
86
     * Amount the light dims along the distance of the light.
87
     *
88
     * @param int $decay            
89
     * @return LightCMPTIF
90
     */
91
    public function decay(int $decay = 1): LightCMPTIF
92
    {
93
        $this->dom_attributes['decay'] = $decay;
94
        return $this;
95
    }
96
97
    /**
98
     * Light distance
99
     *
100
     * Distance where intensity becomes 0. If distance is 0, then the point light does not decay with distance.
101
     *
102
     * @param float $distance            
103
     * @return LightCMPTIF
104
     */
105
    public function distance(float $distance = 0.0): LightCMPTIF
106
    {
107
        $this->dom_attributes['distance'] = $distance;
108
        return $this;
109
    }
110
111
    /**
112
     * falloff
113
     *
114
     * Rapidity of falloff of light from its target direction.
115
     *
116
     * @param float $exponent            
117
     * @return LightCMPTIF
118
     */
119
    public function exponent(float $exponent = 10.0): LightCMPTIF
120
    {
121
        $this->dom_attributes['exponent'] = $exponent;
122
        return $this;
123
    }
124
125
    /**
126
     * Light color from below.
127
     *
128
     * @param string $ground_color            
129
     * @return LightCMPTIF
130
     */
131
    public function groundColor(string $ground_color = '#fff'): LightCMPTIF
132
    {
133
        $this->dom_attributes['groundColor'] = $ground_color;
134
        return $this;
135
    }
136
137
    /**
138
     * Light strength.
139
     *
140
     * @param float $intensity            
141
     * @return LightCMPTIF
142
     */
143
    public function intensity(float $intensity = 1.0): LightCMPTIF
144
    {
145
        $this->dom_attributes['intensity'] = $intensity;
146
        return $this;
147
    }
148
}
149