1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jun 25, 2016 - 7:51:42 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 PositionComponent.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\Geometry; |
25
|
|
|
|
26
|
|
|
use \AframeVR\Core\Helpers\ComponentAbstract; |
27
|
|
|
use \AframeVR\Interfaces\ComponentInterface; |
28
|
|
|
use \AframeVR\Interfaces\Core\Components\Geometry\GeometryInterface; |
29
|
|
|
use \AframeVR\Core\Exceptions\InvalidComponentArgumentException; |
30
|
|
|
|
31
|
|
|
class Component extends ComponentAbstract implements ComponentInterface, GeometryInterface |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* Initialize Component |
35
|
|
|
* |
36
|
|
|
* {@inheritdoc} |
37
|
|
|
* |
38
|
|
|
* @return bool |
39
|
|
|
*/ |
40
|
37 |
|
public function initializeComponent() : bool |
41
|
|
|
{ |
42
|
37 |
|
$this->setDomAttributeName('geometry'); |
43
|
37 |
|
return true; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Return DOM attribute contents |
48
|
|
|
* |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
1 |
|
public function getDomAttributeString() : string |
52
|
|
|
{ |
53
|
1 |
|
$attrs = $this->getDOMAttributesArray(); |
|
|
|
|
54
|
1 |
|
return ''; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Set geometry primitive |
59
|
|
|
* |
60
|
|
|
* One of box, circle, cone, cylinder, plane, ring, sphere, torus, torusKnot. |
61
|
|
|
* |
62
|
|
|
* @param string $primitive |
63
|
|
|
* @throws InvalidComponentArgumentException |
64
|
|
|
* @return void |
65
|
|
|
*/ |
66
|
35 |
|
public function primitive(string $primitive) |
67
|
|
|
{ |
68
|
35 |
|
if (in_array($primitive, self::ALLOWED_PRIMITIVES)) { |
69
|
34 |
|
$this->dom_attributes = array(); |
70
|
34 |
|
$method_provider = sprintf('%sMethods',ucfirst($primitive)); |
71
|
34 |
|
$this->setMethodProvider($method_provider); |
72
|
|
|
} else { |
73
|
2 |
|
throw new InvalidComponentArgumentException((string) $primitive, 'Geometry::primitive'); |
74
|
|
|
} |
75
|
34 |
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* translate |
79
|
|
|
* |
80
|
|
|
* {@inheritdoc} |
81
|
|
|
* |
82
|
|
|
* @param float|int $x |
83
|
|
|
* @param float|int $y |
84
|
|
|
* @param float|int $z |
85
|
|
|
* @return void |
86
|
|
|
*/ |
87
|
7 |
|
public function translate(float $x = 0, float $y = 0, float $z = 0) |
88
|
|
|
{ |
89
|
7 |
|
$this->dom_attributes['translate'] = sprintf('%d %d %d', $x, $y, $z); |
90
|
7 |
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Set Buffer |
94
|
|
|
* |
95
|
|
|
* {@inheritdoc} |
96
|
|
|
* |
97
|
|
|
* @param bool $buffer |
98
|
|
|
* @return void |
99
|
|
|
*/ |
100
|
1 |
|
public function buffer(bool $buffer = true) |
101
|
|
|
{ |
102
|
1 |
|
$this->dom_attributes['buffer'] = $buffer ? 'true' : 'false'; |
103
|
1 |
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* skipCache |
107
|
|
|
* |
108
|
|
|
* {@inheritdoc} |
109
|
|
|
* |
110
|
|
|
* @param bool $skipCache |
111
|
|
|
* @return void |
112
|
|
|
*/ |
113
|
1 |
|
public function skipCache(bool $skipCache = false) |
114
|
|
|
{ |
115
|
1 |
|
$this->dom_attributes['skipCache'] = $skipCache ? 'true' : 'false'; |
116
|
1 |
|
} |
117
|
|
|
} |
118
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.