Completed
Push — master ( f87c77...be4ea7 )
by Marko
02:11
created

AssetVideo::crossorigin()   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 1
crap 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jul 3, 2016 - 7: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         AssetVideo.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\AssetVideoInterface;
27
use \AframeVR\Core\Helpers\AssetsAbstract;
28
29
final class AssetVideo extends AssetsAbstract implements AssetVideoInterface
30
{
31
32
    /**
33
     * Autoplay video
34
     *
35
     * @var bool
36
     */
37
    protected $attr_autoplay;
38
39
    /**
40
     * Preload video
41
     *
42
     * @var string
43
     */
44
    protected $attr_preload;
45
46
    /**
47
     * Image crossorigin
48
     *
49
     * @var string
50
     */
51
    protected $attr_crossorigin;
52
    
53
    /**
54
     * Asset constructor set asset ID
55
     *
56
     * @param string $id            
57
     */
58 1
    public function __construct(string $id)
59
    {
60 1
        $this->id($id);
61 1
        $this->setDomElementTag('video');
62 1
    }
63
64
    /**
65
     * Autoplay video
66
     *
67
     * @param bool $autoplay            
68
     * @return AssetVideoInterface
69
     */
70 1
    public function autoplay(bool $autoplay = true): AssetVideoInterface
71
    {
72 1
        $this->attrs['autoplay'] = $autoplay ? 'true' : 'false';
73 1
        return $this;
74
    }
75
76
    /**
77
     * loop video
78
     *
79
     * @param bool $loop            
80
     * @return AssetVideoInterface
81
     */
82 1
    public function loop(bool $loop = true): AssetVideoInterface
83
    {
84 1
        $this->attrs['loop'] = $loop ? 'true' : 'false';
85 1
        return $this;
86
    }
87
    
88
    /**
89
     * Preload video
90
     *
91
     * @param string $preload
92
     * @return AssetVideoInterface
93
     */
94 1
    public function preload(string $preload = 'auto'): AssetVideoInterface
95
    {
96 1
        $this->attrs['preload'] = $preload;
97 1
        return $this;
98
    }
99
100
    /**
101
     * Set crossorigin attribute of the video
102
     *
103
     * @param string $crossorigin            
104
     * @return AssetVideoInterface
105
     */
106 1
    public function crossorigin(string $crossorigin = 'anonymous'): AssetVideoInterface
107
    {
108 1
        $this->attrs['crossorigin'] = $crossorigin;
109 1
        return $this;
110
    }
111
}
112