Primitives   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 64
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A sky() 0 4 1
A videosphere() 0 4 1
A preparePrimitives() 0 9 3
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jun 20, 2016 - 10:21:07 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         Primitives.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\Extras;
25
26
use \AframeVR\Core\Entity;
27
trait Primitives
28
{
29
30
    /**
31
     * Aframe Document Object Model
32
     *
33
     * @var \AframeVR\Core\DOM\AframeDOMDocument
34
     */
35
    protected $aframeDomObj;
36
37
    /**
38
     * Children entities
39
     *
40
     * @var array $childrens
41
     */
42
    protected $childrens = array();
43
44
    /**
45
     *
46
     * @var \AframeVR\Extras\Primitives\Sky $sky
47
     */
48
    protected $sky;
49
50
    /**
51
     *
52
     * @var \AframeVR\Extras\Primitives\Videosphere $videosphere
53
     */
54
    protected $videosphere;
55
56
    /**
57
     * A-Frame Primitive sky
58
     *
59
     * @return Entity
60
     */
61 2
    public function sky(string $id = '0'): Entity
62
    {
63 2
        return $this->sky = new \AframeVR\Extras\Primitives\Sky($id);
64
    }
65
66
    /**
67
     * A-Frame Primitive videosphere
68
     *
69
     * @return Entity
70
     */
71 2
    public function videosphere(string $id = '0'): Entity
72
    {
73 2
        return $this->videosphere = new \AframeVR\Extras\Primitives\Videosphere($id);
74
    }
75
76
    /**
77
     * Add all used primitevs to the scene
78
     *
79
     * @return void
80
     */
81 24
    protected function preparePrimitives()
82
    {
83
        /* Primitive collections */
84 24
        $this->aframeDomObj->appendEntities($this->childrens);
85
        /* Primitives which only one can be present */
86
87 24
        (! $this->sky) ?: $this->aframeDomObj->appendEntity($this->sky);
88 24
        (! $this->videosphere) ?: $this->aframeDomObj->appendEntity($this->videosphere);
89 24
    }
90
}
91