AssetAudio   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
A autoplay() 0 5 1
A preload() 0 5 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jul 3, 2016 - 6:02:37 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         AssetAudio.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\Assets;
25
26
use \AframeVR\Interfaces\Core\Assets\AssetAudioInterface;
27
use \AframeVR\Core\Helpers\AssetsAbstract;
28
29
final class AssetAudio extends AssetsAbstract implements AssetAudioInterface
30
{
31
32
    /**
33
     * Autoplay audio
34
     *
35
     * @var bool
36
     */
37
    protected $attr_autoplay;
38
39
    /**
40
     * Preload audio
41
     *
42
     * @var string
43
     */
44
    protected $attr_preload;
45
46 1
    public function init()
47
    {
48 1
        $this->setDomElementTag('audio');
49 1
    }
50
51
    /**
52
     * Autoplay audio
53
     *
54
     * @param bool $autoplay            
55
     * @return AssetAudioInterface
56
     */
57 1
    public function autoplay(bool $autoplay = true): AssetAudioInterface
58
    {
59 1
        $this->attr_autoplay = $autoplay;
60 1
        return $this;
61
    }
62
63
    /**
64
     * Preload audio
65
     *
66
     * @param string $preload            
67
     * @return AssetAudioInterface
68
     */
69 1
    public function preload(string $preload = 'auto'): AssetAudioInterface
70
    {
71 1
        $this->attr_preload = $preload;
72 1
        return $this;
73
    }
74
}
75