1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jul 7, 2016 - 2:32:47 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 StatsComponent.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\ascene\Stats; |
25
|
|
|
|
26
|
|
|
use \AframeVR\Interfaces\Core\Components\ascene\StatsCMPTIF; |
27
|
|
|
use \AframeVR\Core\Helpers\ComponentAbstract; |
28
|
|
|
|
29
|
|
View Code Duplication |
class StatsComponent extends ComponentAbstract implements StatsCMPTIF |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
protected $dom_attribute; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Initialize Component |
36
|
|
|
* |
37
|
|
|
* {@inheritdoc} |
38
|
|
|
* |
39
|
|
|
* @return bool |
40
|
|
|
*/ |
41
|
1 |
|
public function initializeComponent(): bool |
42
|
|
|
{ |
43
|
1 |
|
$this->setDomAttribute('stats'); |
44
|
1 |
|
$this->set(); |
45
|
1 |
|
return true; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Entity visible |
50
|
|
|
* |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
* |
53
|
|
|
* @param bool $visible |
54
|
|
|
* @return StatsCMPTIF |
55
|
|
|
*/ |
56
|
1 |
|
public function set(bool $visible = true): StatsCMPTIF |
57
|
|
|
{ |
58
|
1 |
|
$this->dom_attribute = $visible ? 'true' : 'false'; |
59
|
1 |
|
return $this; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Does component have DOM Atributes |
64
|
|
|
* |
65
|
|
|
* If compnent is called then we return true |
66
|
|
|
* |
67
|
|
|
* {@inheritdoc} |
68
|
|
|
* |
69
|
|
|
* @return bool |
70
|
|
|
*/ |
71
|
1 |
|
public function hasDOMAttributes(): bool |
72
|
|
|
{ |
73
|
1 |
|
return true; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Return DOM attribute contents |
78
|
|
|
* |
79
|
|
|
* Scale Components dom atribute contains roll, pitch, yaw |
80
|
|
|
* Ex: rotation="1 1 1" |
81
|
|
|
* |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
1 |
|
public function getDomAttributeString(): string |
85
|
|
|
{ |
86
|
1 |
|
return $this->dom_attribute; |
87
|
|
|
} |
88
|
|
|
} |
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.