| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** @formatter:off | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * ****************************************************************** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * Created by   Marko Kungla on Jun 20, 2016 - 9:08:14 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         Assets.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; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use \AframeVR\Core\Assets\{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     AssetAudio, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     AssetImage, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     AssetItem, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     AssetVideo, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     Mixin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | final class Assets | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * Array of mixins | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     protected $assets; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * Set assets timeout attribute | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @var int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     protected $attr_timeout; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * Asset manager constructor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * @param Config $config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 101 |  |     public function __construct(Config $config) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 101 |  |         $this->assets_uri = $config->get('assets_uri'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 101 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * <a-scene><a-assets><audio> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * @param string $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @return \AframeVR\Interfaces\Core\Assets\AssetAudioInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 1 |  |     public function audio(string $id = '0'): \AframeVR\Interfaces\Core\Assets\AssetAudioInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 1 |  |         return $this->assets[$id] ?? $this->assets[$id] = new AssetAudio($id, $this->assets_uri); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      * <a-scene><a-assets><img> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * @param string $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * @return \AframeVR\Interfaces\Core\Assets\AssetImageInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 1 |  |     public function img(string $id = '0'): \AframeVR\Interfaces\Core\Assets\AssetImageInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 1 |  |         return $this->assets[$id] ?? $this->assets[$id] = new AssetImage($id, $this->assets_uri); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * <a-scene><a-assets><a-asset-item> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * @param string $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * @return \AframeVR\Interfaces\Core\Assets\AssetItemInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 1 |  |     public function item(string $id = '0'): \AframeVR\Interfaces\Core\Assets\AssetItemInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 | 1 |  |         return $this->assets[$id] ?? $this->assets[$id] = new AssetItem($id, $this->assets_uri); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * <a-scene><a-assets><video> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * @param string $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * @return \AframeVR\Interfaces\Core\Assets\AssetVideoInterface | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 99 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 100 | 1 |  |     public function video(string $id = '0'): \AframeVR\Interfaces\Core\Assets\AssetVideoInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 102 | 1 |  |         return $this->assets[$id] ?? $this->assets[$id] = new AssetVideo($id, $this->assets_uri); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      * Mixin which will be directly applied to element usin it | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * A-Frame PHP does not create <a-mixin>. Instead it is appling | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * mixin directly on element using this mixin. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * @param string $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * @return \AframeVR\Interfaces\Core\Assets\MixinInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 3 |  |     public function mixin(string $id = '0'): \AframeVR\Interfaces\Core\Assets\MixinInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 | 3 |  |         return $this->assets[$id] ?? $this->assets[$id] = new Mixin($id, $this->assets_uri); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      * Setting a timeout | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |      * @param int $milliseconds | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |      * @return Assets | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 | 1 |  |     public function timeout(int $milliseconds = 3000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 | 1 |  |         $this->attr_timeout = $milliseconds; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 | 1 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |      * Get all assets | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * @return array|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 | 22 |  |     public function getAssets() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 | 22 |  |         return $this->assets; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 140 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 141 |  |  |  | 
            
                        
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.