@@ -554,7 +554,7 @@ |
||
554 | 554 | /** |
555 | 555 | * Is called method allowed for current primitive |
556 | 556 | * |
557 | - * @param unknown $method |
|
557 | + * @param string $method |
|
558 | 558 | */ |
559 | 559 | protected function isPrimitiveMethod($method) |
560 | 560 | { |
@@ -323,8 +323,9 @@ discard block |
||
323 | 323 | foreach (get_object_vars($this) as $name => $value) { |
324 | 324 | if (empty($value) |
325 | 325 | || (array_key_exists($name, self::P_COMMON_PROPS) && $value === self::P_COMMON_PROPS[$name]) |
326 | - || (array_key_exists($name, $defaults) && $value === $defaults[$name])) |
|
327 | - unset($this->$name); |
|
326 | + || (array_key_exists($name, $defaults) && $value === $defaults[$name])) { |
|
327 | + unset($this->$name); |
|
328 | + } |
|
328 | 329 | } |
329 | 330 | } |
330 | 331 | |
@@ -355,15 +356,17 @@ discard block |
||
355 | 356 | $this->primitive = $primitive; |
356 | 357 | $defaults = $this->primitiveDefaults(); |
357 | 358 | foreach (get_class_vars(get_class($this)) as $name => $default) { |
358 | - if ($name === 'primitive') |
|
359 | - continue; |
|
359 | + if ($name === 'primitive') { |
|
360 | + continue; |
|
361 | + } |
|
360 | 362 | |
361 | - if (array_key_exists($name, $defaults)) |
|
362 | - $this->$name = $defaults[$name]; |
|
363 | - elseif (array_key_exists($name, self::P_COMMON_PROPS)) |
|
364 | - $this->$name = self::P_COMMON_PROPS[$name]; |
|
365 | - else |
|
366 | - unset($this->$name); |
|
363 | + if (array_key_exists($name, $defaults)) { |
|
364 | + $this->$name = $defaults[$name]; |
|
365 | + } elseif (array_key_exists($name, self::P_COMMON_PROPS)) { |
|
366 | + $this->$name = self::P_COMMON_PROPS[$name]; |
|
367 | + } else { |
|
368 | + unset($this->$name); |
|
369 | + } |
|
367 | 370 | } |
368 | 371 | } else { |
369 | 372 | throw new InvalidComponentArgumentException($primitive, 'Geometry::primitive'); |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public function hasDOMAttributes(): bool |
311 | 311 | { |
312 | - return ! empty(get_object_vars($this)); |
|
312 | + return !empty(get_object_vars($this)); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -320,8 +320,8 @@ discard block |
||
320 | 320 | public function removeDefaultDOMAttributes() |
321 | 321 | { |
322 | 322 | $defaults = $this->primitiveDefaults(); |
323 | - foreach (get_object_vars($this) as $name => $value) { |
|
324 | - if (empty($value) |
|
323 | + foreach(get_object_vars($this) as $name => $value) { |
|
324 | + if(empty($value) |
|
325 | 325 | || (array_key_exists($name, self::P_COMMON_PROPS) && $value === self::P_COMMON_PROPS[$name]) |
326 | 326 | || (array_key_exists($name, $defaults) && $value === $defaults[$name])) |
327 | 327 | unset($this->$name); |
@@ -350,17 +350,17 @@ discard block |
||
350 | 350 | public function primitive($primitive = null) |
351 | 351 | { |
352 | 352 | try { |
353 | - if (in_array($primitive, self::ALLOWED_PRIMITIVES)) { |
|
353 | + if(in_array($primitive, self::ALLOWED_PRIMITIVES)) { |
|
354 | 354 | /* If primitive is changed we reset the object and releoad allowed attributes */ |
355 | 355 | $this->primitive = $primitive; |
356 | 356 | $defaults = $this->primitiveDefaults(); |
357 | - foreach (get_class_vars(get_class($this)) as $name => $default) { |
|
358 | - if ($name === 'primitive') |
|
357 | + foreach(get_class_vars(get_class($this)) as $name => $default) { |
|
358 | + if($name === 'primitive') |
|
359 | 359 | continue; |
360 | 360 | |
361 | - if (array_key_exists($name, $defaults)) |
|
361 | + if(array_key_exists($name, $defaults)) |
|
362 | 362 | $this->$name = $defaults[$name]; |
363 | - elseif (array_key_exists($name, self::P_COMMON_PROPS)) |
|
363 | + elseif(array_key_exists($name, self::P_COMMON_PROPS)) |
|
364 | 364 | $this->$name = self::P_COMMON_PROPS[$name]; |
365 | 365 | else |
366 | 366 | unset($this->$name); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | } else { |
369 | 369 | throw new InvalidComponentArgumentException($primitive, 'Geometry::primitive'); |
370 | 370 | } |
371 | - } catch (InvalidComponentArgumentException $e) { |
|
371 | + } catch(InvalidComponentArgumentException $e) { |
|
372 | 372 | die($e->getMessage()); |
373 | 373 | } |
374 | 374 | } |
@@ -531,14 +531,14 @@ discard block |
||
531 | 531 | */ |
532 | 532 | public function __call($method, $args) |
533 | 533 | { |
534 | - if ($method === 'primitive') { |
|
534 | + if($method === 'primitive') { |
|
535 | 535 | return call_user_func_array(array( |
536 | 536 | $this, |
537 | 537 | $method |
538 | 538 | ), $args); |
539 | 539 | } |
540 | 540 | try { |
541 | - if (method_exists($this, $method) && $this->isPrimitiveMethod($method)) { |
|
541 | + if(method_exists($this, $method) && $this->isPrimitiveMethod($method)) { |
|
542 | 542 | return call_user_func_array(array( |
543 | 543 | $this, |
544 | 544 | $method |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | } else { |
547 | 547 | throw new InvalidComponentMethodException($method, 'Geometry::primitive ' . $this->primitive); |
548 | 548 | } |
549 | - } catch (InvalidComponentMethodException $e) { |
|
549 | + } catch(InvalidComponentMethodException $e) { |
|
550 | 550 | die($e->getMessage()); |
551 | 551 | } |
552 | 552 | } |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | */ |
559 | 559 | protected function isPrimitiveMethod($method) |
560 | 560 | { |
561 | - switch ($this->primitive) { |
|
561 | + switch($this->primitive) { |
|
562 | 562 | case 'box': |
563 | 563 | return in_array($method, self::P_BOX) ? self::P_BOX : false; |
564 | 564 | break; |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | */ |
600 | 600 | protected function primitiveDefaults() : array |
601 | 601 | { |
602 | - switch ($this->primitive) { |
|
602 | + switch($this->primitive) { |
|
603 | 603 | case 'box': |
604 | 604 | return self::P_BOX; |
605 | 605 | break; |
@@ -120,7 +120,7 @@ |
||
120 | 120 | /** |
121 | 121 | * Get DOMAttr for the entity |
122 | 122 | * |
123 | - * @return DOMAttr |
|
123 | + * @return \DOMAttr |
|
124 | 124 | */ |
125 | 125 | public function getDOMAttributes(): \DOMAttr |
126 | 126 | { |
@@ -109,8 +109,9 @@ discard block |
||
109 | 109 | 'side' => 'front' |
110 | 110 | ); |
111 | 111 | foreach (get_object_vars($this) as $name => $value) { |
112 | - if (empty($value) || (array_key_exists($name, $defaults) && $value === $defaults[$name])) |
|
113 | - unset($this->$name); |
|
112 | + if (empty($value) || (array_key_exists($name, $defaults) && $value === $defaults[$name])) { |
|
113 | + unset($this->$name); |
|
114 | + } |
|
114 | 115 | } |
115 | 116 | |
116 | 117 | /* Remove defaults from current shader */ |
@@ -131,8 +132,9 @@ discard block |
||
131 | 132 | 'side' => $this->side ?? null |
132 | 133 | ); |
133 | 134 | foreach ($material as $key => $val) { |
134 | - if (empty($val) || ! property_exists($key, $this)) |
|
135 | - unset($material[$key]); |
|
135 | + if (empty($val) || ! property_exists($key, $this)) { |
|
136 | + unset($material[$key]); |
|
137 | + } |
|
136 | 138 | } |
137 | 139 | if (! empty($material)) { |
138 | 140 | $material_format = implode(': %s; ', array_keys($material)) . ': %s;'; |
@@ -155,8 +157,9 @@ discard block |
||
155 | 157 | */ |
156 | 158 | public function shader($shader = 'standard') |
157 | 159 | { |
158 | - if ($this->shaderObj instanceof ShaderInterface) |
|
159 | - return $this->shaderObj; |
|
160 | + if ($this->shaderObj instanceof ShaderInterface) { |
|
161 | + return $this->shaderObj; |
|
162 | + } |
|
160 | 163 | |
161 | 164 | try { |
162 | 165 | $shader = sprintf('\AframeVR\Core\Shaders\%s', ucfirst($shader)); |
@@ -129,4 +129,4 @@ |
||
129 | 129 | $this->z = $z ?? 0; |
130 | 130 | } |
131 | 131 | } |
132 | - |
|
133 | 132 | \ No newline at end of file |
133 | + |
|
134 | 134 | \ No newline at end of file |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function hasDOMAttributes(): bool |
94 | 94 | { |
95 | - return ! empty(get_object_vars($this)) || ! empty(get_object_vars($this->shaderObj)); |
|
95 | + return !empty(get_object_vars($this)) || !empty(get_object_vars($this->shaderObj)); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | 'transparent' => 'false', |
109 | 109 | 'side' => 'front' |
110 | 110 | ); |
111 | - foreach (get_object_vars($this) as $name => $value) { |
|
112 | - if (empty($value) || (array_key_exists($name, $defaults) && $value === $defaults[$name])) |
|
111 | + foreach(get_object_vars($this) as $name => $value) { |
|
112 | + if(empty($value) || (array_key_exists($name, $defaults) && $value === $defaults[$name])) |
|
113 | 113 | unset($this->$name); |
114 | 114 | } |
115 | 115 | |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | 'transparent' => $this->transparent ?? null, |
131 | 131 | 'side' => $this->side ?? null |
132 | 132 | ); |
133 | - foreach ($material as $key => $val) { |
|
134 | - if (empty($val) || ! property_exists($key, $this)) |
|
133 | + foreach($material as $key => $val) { |
|
134 | + if(empty($val) || !property_exists($key, $this)) |
|
135 | 135 | unset($material[$key]); |
136 | 136 | } |
137 | - if (! empty($material)) { |
|
137 | + if(!empty($material)) { |
|
138 | 138 | $material_format = implode(': %s; ', array_keys($material)) . ': %s;'; |
139 | 139 | $attributes[] = vsprintf($material_format, array_values($material)); |
140 | 140 | } |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function shader($shader = 'standard') |
157 | 157 | { |
158 | - if ($this->shaderObj instanceof ShaderInterface) |
|
158 | + if($this->shaderObj instanceof ShaderInterface) |
|
159 | 159 | return $this->shaderObj; |
160 | 160 | |
161 | 161 | try { |
162 | 162 | $shader = sprintf('\AframeVR\Core\Shaders\%s', ucfirst($shader)); |
163 | - if (class_exists($shader)) { |
|
163 | + if(class_exists($shader)) { |
|
164 | 164 | $this->shaderObj = new $shader(); |
165 | 165 | } else { |
166 | 166 | throw new BadShaderCallException($shader); |
167 | 167 | } |
168 | - } catch (BadShaderCallException $e) { |
|
168 | + } catch(BadShaderCallException $e) { |
|
169 | 169 | die($e->getMessage()); |
170 | 170 | } |
171 | 171 | return $this->shaderObj; |
@@ -62,7 +62,6 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * Set initial coordinates |
64 | 64 | * |
65 | - * @param string $coordinates |
|
66 | 65 | */ |
67 | 66 | public function __construct($x = 0, $y = 0, $z = 0) |
68 | 67 | { |
@@ -110,7 +109,7 @@ discard block |
||
110 | 109 | /** |
111 | 110 | * Get DOMAttr for the entity |
112 | 111 | * |
113 | - * @return DOMAttr |
|
112 | + * @return \DOMAttr |
|
114 | 113 | */ |
115 | 114 | public function getDOMAttributes(): \DOMAttr |
116 | 115 | { |
@@ -120,7 +119,6 @@ discard block |
||
120 | 119 | /** |
121 | 120 | * Update coordinates |
122 | 121 | * |
123 | - * @param string $coordinates |
|
124 | 122 | */ |
125 | 123 | public function update($x = 0, $y = 0, $z = 0) |
126 | 124 | { |
@@ -129,4 +129,4 @@ |
||
129 | 129 | $this->z = $z ?? 0; |
130 | 130 | } |
131 | 131 | } |
132 | - |
|
133 | 132 | \ No newline at end of file |
133 | + |
|
134 | 134 | \ No newline at end of file |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function hasDOMAttributes(): bool |
92 | 92 | { |
93 | - return ! empty(get_object_vars($this)); |
|
93 | + return !empty(get_object_vars($this)); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function removeDefaultDOMAttributes() |
102 | 102 | { |
103 | - if ($this->x === 0 && $this->y === 0 && $this->z === 0) { |
|
103 | + if($this->x === 0 && $this->y === 0 && $this->z === 0) { |
|
104 | 104 | unset($this->x); |
105 | 105 | unset($this->y); |
106 | 106 | unset($this->z); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * material.metalness |
53 | 53 | * |
54 | - * @param string $metalness |
|
54 | + * @param integer $metalness |
|
55 | 55 | * @return \AframeVR\Core\Helpers\MeshAttributes |
56 | 56 | */ |
57 | 57 | public function metalness($metalness = 0) |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * material.roughness |
67 | 67 | * |
68 | - * @param string $roughness |
|
68 | + * @param double $roughness |
|
69 | 69 | * @return \AframeVR\Core\Helpers\MeshAttributes |
70 | 70 | */ |
71 | 71 | public function roughness($roughness = 0.5) |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * material.opacity |
121 | 121 | * |
122 | - * @param string $opacity |
|
122 | + * @param integer $opacity |
|
123 | 123 | * @return \AframeVR\Core\Helpers\MeshAttributes |
124 | 124 | */ |
125 | 125 | public function opacity($opacity = 0) |
@@ -33,6 +33,9 @@ |
||
33 | 33 | |
34 | 34 | private $name; |
35 | 35 | |
36 | + /** |
|
37 | + * @param string $name |
|
38 | + */ |
|
36 | 39 | public function __construct($name) |
37 | 40 | { |
38 | 41 | $this->name = $name; |
@@ -129,4 +129,4 @@ |
||
129 | 129 | $this->z = $z ?? 0; |
130 | 130 | } |
131 | 131 | } |
132 | - |
|
133 | 132 | \ No newline at end of file |
133 | + |
|
134 | 134 | \ No newline at end of file |
@@ -14,7 +14,8 @@ |
||
14 | 14 | ), $class); |
15 | 15 | |
16 | 16 | $class_file = AFRAME_ROOT . $library . '.php'; |
17 | - if (file_exists($class_file)) |
|
18 | - require_once ($class_file); |
|
19 | -} |
|
17 | + if (file_exists($class_file)) { |
|
18 | + require_once ($class_file); |
|
19 | + } |
|
20 | + } |
|
20 | 21 | spl_autoload_register('aframe_autoloder'); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | define("AFRAME_ROOT", dirname(__FILE__)); |
3 | 3 | /* Paths */ |
4 | -define("AFRAME_TMP", AFRAME_ROOT.DIRECTORY_SEPARATOR.'tmp'); |
|
4 | +define("AFRAME_TMP", AFRAME_ROOT . DIRECTORY_SEPARATOR . 'tmp'); |
|
5 | 5 | |
6 | 6 | function aframe_autoloder($class = false) |
7 | 7 | { |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | ), $class); |
15 | 15 | |
16 | 16 | $class_file = AFRAME_ROOT . $library . '.php'; |
17 | - if (file_exists($class_file)) |
|
17 | + if(file_exists($class_file)) |
|
18 | 18 | require_once ($class_file); |
19 | 19 | } |
20 | 20 | spl_autoload_register('aframe_autoloder'); |
@@ -65,8 +65,9 @@ |
||
65 | 65 | { |
66 | 66 | $defaults = get_class_vars(get_class($this)); |
67 | 67 | foreach (get_object_vars($this) as $name => $value) { |
68 | - if (empty($value) || (array_key_exists($name, $defaults) && $value === $defaults[$name])) |
|
69 | - unset($this->$name); |
|
68 | + if (empty($value) || (array_key_exists($name, $defaults) && $value === $defaults[$name])) { |
|
69 | + unset($this->$name); |
|
70 | + } |
|
70 | 71 | } |
71 | 72 | } |
72 | 73 | } |
@@ -64,8 +64,8 @@ |
||
64 | 64 | public function removeDefaultDOMAttributes() |
65 | 65 | { |
66 | 66 | $defaults = get_class_vars(get_class($this)); |
67 | - foreach (get_object_vars($this) as $name => $value) { |
|
68 | - if (empty($value) || (array_key_exists($name, $defaults) && $value === $defaults[$name])) |
|
67 | + foreach(get_object_vars($this) as $name => $value) { |
|
68 | + if(empty($value) || (array_key_exists($name, $defaults) && $value === $defaults[$name])) |
|
69 | 69 | unset($this->$name); |
70 | 70 | } |
71 | 71 | } |
@@ -129,8 +129,9 @@ |
||
129 | 129 | * Check does component has any attributes to add to DOM element. |
130 | 130 | * default attributes most of cases are ommited so we might not have any attributes to add |
131 | 131 | */ |
132 | - if ($component->hasDOMAttributes()) |
|
133 | - $a_entity->setAttributeNode($component->getDOMAttributes()); |
|
132 | + if ($component->hasDOMAttributes()) { |
|
133 | + $a_entity->setAttributeNode($component->getDOMAttributes()); |
|
134 | + } |
|
134 | 135 | } |
135 | 136 | return $a_entity; |
136 | 137 | } |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | { |
75 | 75 | $component_name = strtolower($component_name); |
76 | 76 | |
77 | - if (! array_key_exists($component_name, $this->components)) { |
|
77 | + if(!array_key_exists($component_name, $this->components)) { |
|
78 | 78 | try { |
79 | 79 | $component = sprintf('\AframeVR\Components\%s', ucfirst($component_name)); |
80 | - if (class_exists($component)) { |
|
80 | + if(class_exists($component)) { |
|
81 | 81 | $this->components[$component_name] = new $component(); |
82 | 82 | } else { |
83 | 83 | throw new BadComponentCallException($component_name); |
84 | 84 | } |
85 | - } catch (BadComponentCallException $e) { |
|
85 | + } catch(BadComponentCallException $e) { |
|
86 | 86 | die($e->getMessage()); |
87 | 87 | } |
88 | 88 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | /* Create entity DOMElement */ |
122 | 122 | $a_entity = $aframe_dom->createElement('a-entity', "\n"); |
123 | - foreach ($this->components as $component) { |
|
123 | + foreach($this->components as $component) { |
|
124 | 124 | /** |
125 | 125 | * Remeve component default properties which are not needed |
126 | 126 | */ |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * Check does component has any attributes to add to DOM element. |
130 | 130 | * default attributes most of cases are ommited so we might not have any attributes to add |
131 | 131 | */ |
132 | - if ($component->hasDOMAttributes()) |
|
132 | + if($component->hasDOMAttributes()) |
|
133 | 133 | $a_entity->setAttributeNode($component->getDOMAttributes()); |
134 | 134 | } |
135 | 135 | return $a_entity; |
@@ -62,7 +62,6 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * Set initial coordinates |
64 | 64 | * |
65 | - * @param string $coordinates |
|
66 | 65 | */ |
67 | 66 | public function __construct($x = 0, $y = 0, $z = 0) |
68 | 67 | { |
@@ -110,7 +109,7 @@ discard block |
||
110 | 109 | /** |
111 | 110 | * Get DOMAttr for the entity |
112 | 111 | * |
113 | - * @return DOMAttr |
|
112 | + * @return \DOMAttr |
|
114 | 113 | */ |
115 | 114 | public function getDOMAttributes(): \DOMAttr |
116 | 115 | { |
@@ -120,7 +119,6 @@ discard block |
||
120 | 119 | /** |
121 | 120 | * Update coordinates |
122 | 121 | * |
123 | - * @param string $coordinates |
|
124 | 122 | */ |
125 | 123 | public function update($x = 0, $y = 0, $z = 0) |
126 | 124 | { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function hasDOMAttributes(): bool |
91 | 91 | { |
92 | - return ! empty(get_object_vars($this)); |
|
92 | + return !empty(get_object_vars($this)); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function removeDefaultDOMAttributes() |
101 | 101 | { |
102 | - if ($this->x === 0 && $this->y === 0 && $this->z === 0) { |
|
102 | + if($this->x === 0 && $this->y === 0 && $this->z === 0) { |
|
103 | 103 | unset($this->x); |
104 | 104 | unset($this->y); |
105 | 105 | unset($this->z); |