| @@ 55-68 (lines=14) @@ | ||
| 52 | * @throws \AframeVR\Core\Exceptions\BadComponentCallException |
|
| 53 | * @return object|null |
|
| 54 | */ |
|
| 55 | public function component(string $component_name) |
|
| 56 | { |
|
| 57 | if (! array_key_exists($component_name, $this->components)) { |
|
| 58 | $component = sprintf('\AframeVR\Core\Components\%s\%sComponent', ucfirst($component_name), |
|
| 59 | ucfirst($component_name)); |
|
| 60 | if (class_exists($component)) { |
|
| 61 | $this->components[$component_name] = new $component(); |
|
| 62 | } else { |
|
| 63 | throw new BadComponentCallException($component_name); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| 67 | return $this->components[$component_name] ?? null; |
|
| 68 | } |
|
| 69 | ||
| 70 | /** |
|
| 71 | * Handle entity components |
|
| @@ 214-227 (lines=14) @@ | ||
| 211 | * @throws \AframeVR\Core\Exceptions\BadComponentCallException |
|
| 212 | * @return object|null |
|
| 213 | */ |
|
| 214 | public function component(string $component_name) |
|
| 215 | { |
|
| 216 | if (! array_key_exists($component_name, $this->components)) { |
|
| 217 | $component = sprintf('\AframeVR\Core\Components\%s\%sComponent', ucfirst($component_name), |
|
| 218 | ucfirst($component_name)); |
|
| 219 | if (class_exists($component)) { |
|
| 220 | $this->components[$component_name] = new $component(); |
|
| 221 | } else { |
|
| 222 | throw new BadComponentCallException($component_name); |
|
| 223 | } |
|
| 224 | } |
|
| 225 | ||
| 226 | return $this->components[$component_name] ?? null; |
|
| 227 | } |
|
| 228 | ||
| 229 | /** |
|
| 230 | * Handle entity components |
|
| @@ 210-223 (lines=14) @@ | ||
| 207 | * @throws \AframeVR\Core\Exceptions\BadComponentCallException |
|
| 208 | * @return object|null |
|
| 209 | */ |
|
| 210 | public function component(string $component_name) |
|
| 211 | { |
|
| 212 | if (! array_key_exists($component_name, $this->components)) { |
|
| 213 | $component = sprintf('\AframeVR\Core\Components\ascene\%s\%sComponent', ucfirst($component_name), |
|
| 214 | ucfirst($component_name)); |
|
| 215 | if (class_exists($component)) { |
|
| 216 | $this->components[$component_name] = new $component(); |
|
| 217 | } else { |
|
| 218 | throw new BadComponentCallException($component_name); |
|
| 219 | } |
|
| 220 | } |
|
| 221 | ||
| 222 | return $this->components[$component_name] ?? null; |
|
| 223 | } |
|
| 224 | ||
| 225 | ||
| 226 | /** |
|