Completed
Push — master ( 0aef32...b40f7e )
by Marko
02:52
created

Assets::mixin()   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 - 9:08:14 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         Assets.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;
25
26
use \AframeVR\Interfaces\Assets\{
27
    ItemInterface,
28
    MixinInterface
29
};
30
use \AframeVR\Core\Assets\{
31
    Mixin,
32
    Item
33
};
34
35
final class Assets
36
{
37
38
    /**
39
     * Array of mixins
40
     * 
41
     * @var array
42
     */
43
    protected $assets;
44
45
46
    /**
47
     * mixin
48
     *
49
     * @param string $name            
50
     * @return MixinInterface
0 ignored issues
show
Documentation introduced by
Should the return type not be \AframeVR\Interfaces\Assets\MixinInterface?

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...
51
     */
52 1
    public function mixin(string $name = 'untitled'): MixinInterface
53
    {
54 1
        return $this->assets[$name] ?? $this->assets[$name] = new Mixin($name);
0 ignored issues
show
Unused Code introduced by
The call to Mixin::__construct() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
55
    }
56
    
57
    /**
58
     * mixin
59
     *
60
     * @param string $name
61
     * @return ItemInterface
0 ignored issues
show
Documentation introduced by
Should the return type not be \AframeVR\Interfaces\Assets\ItemInterface?

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...
62
     */
63 4
    public function item(string $name = 'untitled'): ItemInterface
64
    {
65 4
        return $this->assets[$name] ?? $this->assets[$name] = new Item($name);
66
    }
67
    
68
    /**
69
     * Get all assets
70
     * 
71
     * @return array|null
72
     */
73 7
    public function getAssets()
74
    {
75 7
        return $this->assets;
76
    }
77
}
78