Completed
Branch 0.3.x (efbbbe)
by Marko
02:32
created

AssetVideo::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
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
     * Asset constructor set asset ID
48
     *
49
     * @param string $id            
50
     */
51 1
    public function __construct(string $id)
52
    {
53 1
        $this->id($id);
54 1
        $this->setDomElementTag('video');
55 1
    }
56
57
    /**
58
     * Autoplay video
59
     *
60
     * @param bool $autoplay            
61
     * @return AssetVideoInterface
62
     */
63 1
    public function autoplay(bool $autoplay = true): AssetVideoInterface
64
    {
65 1
        $this->attr_autoplay = $autoplay;
66 1
        return $this;
67
    }
68
69
    /**
70
     * Preload video
71
     *
72
     * @param string $preload            
73
     * @return AssetVideoInterface
74
     */
75 1
    public function preload(string $preload = 'auto'): AssetVideoInterface
76
    {
77 1
        $this->attr_preload = $preload;
78 1
        return $this;
79
    }
80
81
    /**
82
     * Set crossorigin attribute of the video
83
     *
84
     * @param string $crossorigin            
85
     * @return AssetVideoInterface
86
     */
87 1
    public function crossorigin(string $crossorigin = 'anonymous'): AssetVideoInterface
88
    {
89 1
        $this->attr_crossorigin = $crossorigin;
0 ignored issues
show
Bug introduced by
The property attr_crossorigin does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
90 1
        return $this;
91
    }
92
}
93