1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jun 28, 2016 - 3:47:35 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 AssetsAbstract.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\Helpers; |
25
|
|
|
|
26
|
|
|
use \AframeVR\Interfaces\AssetsInterface; |
27
|
|
|
use \DOMElement; |
28
|
|
|
|
29
|
|
|
abstract class AssetsAbstract implements AssetsInterface |
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* DOM tag name of asset item |
34
|
|
|
* |
35
|
|
|
* @var string $element_name |
36
|
|
|
*/ |
37
|
|
|
protected $element_name = 'a-asset-item'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* ID attribute |
41
|
|
|
* |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
protected $attr_id; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* SRC attribute |
48
|
|
|
* |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
protected $attr_src; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Asset constructor set asset ID |
55
|
|
|
* |
56
|
|
|
* @param string $id |
57
|
|
|
*/ |
58
|
4 |
|
public function __construct(string $id) |
59
|
|
|
{ |
60
|
4 |
|
$this->id($id); |
61
|
4 |
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Set ID attribute of the asset |
65
|
|
|
* |
66
|
|
|
* {@inheritdoc} |
67
|
|
|
* |
68
|
|
|
* @param string $id |
69
|
|
|
*/ |
70
|
4 |
|
public function id(string $id = 'untitled') |
71
|
|
|
{ |
72
|
4 |
|
$this->attr_id = $id; |
73
|
4 |
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Set Assets src attribute |
77
|
|
|
* |
78
|
|
|
* {@inheritdoc} |
79
|
|
|
* |
80
|
|
|
* @param string $src |
|
|
|
|
81
|
|
|
* @return void |
82
|
|
|
*/ |
83
|
3 |
|
public function src(string $src = null) |
84
|
|
|
{ |
85
|
3 |
|
$this->attr_src = $src; |
86
|
3 |
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Create and add DOM element of the asset |
90
|
|
|
* |
91
|
|
|
* @param \DOMDocument $aframe_dom |
92
|
|
|
* @return \DOMElement |
93
|
|
|
*/ |
94
|
2 |
|
public function DOMElement(&$aframe_dom): DOMElement |
95
|
|
|
{ |
96
|
2 |
|
$a_asset = $aframe_dom->createElement($this->element_name); |
97
|
2 |
|
$a_asset->setAttribute('id',$this->attr_id); |
98
|
|
|
//$a_asset->setAttributeNode($this->idDOMAttr()); |
99
|
2 |
|
return $a_asset; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
} |
103
|
|
|
|
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.