Completed
Push — master ( 270ac9...fb685e )
by Marko
02:19
created

Aframe::scene()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jun 20, 2016 - 8:45:32 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         Aframe.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;
25
26
use \AframeVR\Core\{
27
    Config,
28
    Scene
29
};
30
31
final class Aframe
32
{
33
34
    /**
35
     * A-Frame Scenes
36
     *
37
     * All scenes will be in this array as Scene objects with index of custom identifier.
38
     *
39
     * @var $scenes
40
     */
41
    private $scenes;
42
43
    private $configObj;
44
45
    /**
46
     * Constructor
47
     */
48 58
    public function __construct()
49
    {
50
        /* We will have scenes in array */
51 58
        $this->scenes = array();
52 58
    }
53
54 1
    public function config()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
55
    {
56 1
        return $this->configObj ?? $this->configObj = new Config();
57
    }
58
59
    /**
60
     * Scene
61
     *
62
     * Work with untitled scene or scene by name
63
     *
64
     * @param string $name            
65
     * @return Scene
0 ignored issues
show
Documentation introduced by
Should the return type not be Core\Scene?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
66
     */
67 56
    public function scene(string $name = 'untitled'): Scene
68
    {
69 56
        return $this->scenes[$name] ?? $this->scenes[$name] = new Scene($name);
70
    }
71
}
72