Completed
Push — 0.3.x ( 4f6fde...8ea901 )
by Marko
02:33
created

ColladaModelComponent::initializeComponent()   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 0
crap 1
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 string $src
0 ignored issues
show
Documentation introduced by
Should the type for parameter $src not be null|string?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
50
     */
51 3
    public function src( string $src = null)
52
    {
53 3
        $this->dom_attributes['src'] = $src;
54 3
    }
55
56
    /**
57
     * Return DOM attribute contents
58
     * 
59
     * @return string
60
     */
61 2
    public function getDomAttributeString(): string
62
    {
63 2
        $attr = substr($this->dom_attributes['src'], 0, 1) === '#' 
64 2
            ? $this->dom_attributes['src'] 
65 2
            : sprintf('url(%s)', $this->dom_attributes['src']);
66 2
        return $attr;
67
    }
68
}
69