Completed
Push — master ( 95af13...697c38 )
by Marko
8s
created

ColladaModelComponent::getDomAttributeString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
crap 2
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jul 4, 2016 - 6:14:02 AM
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         ColladaModelComponent.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\ColladaModel;
25
26
use \AframeVR\Interfaces\Core\Components\ColladaModel\ColladaModelInterface;
27
use \AframeVR\Core\Helpers\ComponentAbstract;
28
29
class ColladaModelComponent extends ComponentAbstract implements ColladaModelInterface
30
{
31
    /**
32
     * Initialize Component
33
     * 
34
     * {@inheritdoc}
35
     *
36
     * @return bool
37
     */
38 3
    public function initializeComponent(): bool
39
    {
40 3
        $this->setDomAttribute('collada-model');
41 3
        return true;
42
    }
43
44
    /**
45
     * pointing to an asset that specifies the src or url()
46
     * 
47
     * {@inheritdoc}
48
     * 
49
     * @param null|string $src
50
     * @return void
51
     */
52 3
    public function src( string $src = null)
53
    {
54 3
        $this->dom_attributes['src'] = $src;
55 3
    }
56
57
    /**
58
     * Return DOM attribute contents
59
     * 
60
     * @return string
61
     */
62 2
    public function getDomAttributeString(): string
63
    {
64 2
        $attr = substr($this->dom_attributes['src'], 0, 1) === '#' 
65 2
            ? $this->dom_attributes['src'] 
66 2
            : sprintf('url(%s)', $this->dom_attributes['src']);
67 2
        return $attr;
68
    }
69
}
70