Completed
Push — master ( 507e84...e8c35c )
by Marko
03:03
created

GeometryComponent::translate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 3
crap 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jun 25, 2016 - 7:51:42 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         GeometryComponent.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\Components\Geometry;
25
26
use \AframeVR\Interfaces\Core\Components\GeometryCMPTIF;
27
use \AframeVR\Core\Helpers\ComponentAbstract;
28
use \AframeVR\Core\Exceptions\InvalidComponentArgumentException;
29
30
class GeometryComponent extends ComponentAbstract implements GeometryCMPTIF
31
{
32
33
    /**
34
     * Initialize Component
35
     *
36
     * {@inheritdoc}
37
     *
38
     * @return bool
39
     */
40 38
    public function initializeComponent(): bool
41
    {
42 38
        $this->setDomAttribute('geometry');
43 38
        return true;
44
    }
45
46
    /**
47
     * Set geometry primitive
48
     *
49
     * {@inheritdoc}
50
     *
51
     * @param string $primitive            
52
     * @throws InvalidComponentArgumentException
53
     * @return GeometryCMPTIF
54
     */
55 36
    public function primitive(string $primitive): GeometryCMPTIF
56
    {
57 36
        if (in_array($primitive, self::ALLOWED_PRIMITIVES)) {
58 35
            $this->dom_attributes = array();
59
            
60 35
            $method_provider = sprintf('%sMethods', ucfirst($primitive));
61
            
62 35
            $this->dom_attributes['primitive'] = $primitive;
63
            
64 35
            $this->setMethodProvider($method_provider);
65
        } else {
66 2
            throw new InvalidComponentArgumentException((string) $primitive, 'Geometry::primitive');
67
        }
68 35
        return $this;
69
    }
70
71
    /**
72
     * Set Buffer
73
     *
74
     * {@inheritdoc}
75
     *
76
     * @param bool $buffer            
77
     * @return GeometryCMPTIF
78
     */
79 1
    public function buffer(bool $buffer = true): GeometryCMPTIF
80
    {
81 1
        $this->dom_attributes['buffer'] = $buffer ? 'true' : 'false';
82 1
        return $this;
83
    }
84
85
    /**
86
     * skipCache
87
     *
88
     * {@inheritdoc}
89
     *
90
     * @param bool $skipCache            
91
     * @return GeometryCMPTIF
92
     */
93 1
    public function skipCache(bool $skipCache = false): GeometryCMPTIF
94
    {
95 1
        $this->dom_attributes['skipCache'] = $skipCache ? 'true' : 'false';
96 1
        return $this;
97
    }
98
}
99