1
|
|
|
<?php namespace FlatPlan\Components; |
2
|
|
|
|
3
|
|
|
class Video extends AbstractComponent { |
4
|
|
|
|
5
|
|
|
protected $url; |
6
|
|
|
protected $aspectRatio; |
7
|
|
|
protected $caption; |
8
|
|
|
protected $accessibilityCaption; |
9
|
|
|
protected $expicitContent; |
10
|
|
|
|
11
|
|
|
protected $roles = ['video', 'embedwebvideo', 'embedvideo']; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @param string $url |
15
|
|
|
* @param string $role |
16
|
|
|
* @param float $aspectRatio |
17
|
|
|
* @param string $caption |
18
|
|
|
* @param string $accessibilityCaption |
19
|
|
|
* @param bool $explicitContent |
20
|
|
|
* @return void |
21
|
|
|
*/ |
22
|
|
|
public function __construct($url, $role, $aspectRatio = 1.777, $caption = '', $accessibilityCaption = '', $explicitContent = false) |
23
|
|
|
{ |
24
|
|
|
$this->setUrl($url); |
25
|
|
|
$this->setRole($role); |
26
|
|
|
$this->setAspectRatio($aspectRatio); |
27
|
|
|
$this->setCaption($caption); |
28
|
|
|
$this->setAccessibilityCaption($accessibilityCaption); |
29
|
|
|
$this->setExplicitContent($explicitContent); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
private function setUrl($url) |
33
|
|
|
{ |
34
|
|
|
if (!filter_var($url, FILTER_VALIDATE_URL)) { |
35
|
|
|
throw new \ErrorException('Invalid url supplied.'); |
36
|
|
|
} |
37
|
|
|
$this->url = $url; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
private function getUrl() |
41
|
|
|
{ |
42
|
|
|
return $this->url; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
private function setAspectRatio($aspectRatio) |
46
|
|
|
{ |
47
|
|
|
$this->aspectRatio = (float) $aspectRatio; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
private function getAspectRatio() |
51
|
|
|
{ |
52
|
|
|
return $this->aspectRatio; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
private function setCaption($caption) |
56
|
|
|
{ |
57
|
|
|
$this->caption = $caption; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
private function getCaption() |
61
|
|
|
{ |
62
|
|
|
return $this->caption; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
private function setAccessibilityCaption($accessibilityCaption) |
66
|
|
|
{ |
67
|
|
|
$this->accessibilityCaption = $accessibilityCaption; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
private function getAccessibilityCaption() |
71
|
|
|
{ |
72
|
|
|
return $this->accessibilityCaption; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
private function setExplicitContent($expicitContent) |
76
|
|
|
{ |
77
|
|
|
$this->expicitContent = $expicitContent; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
private function getExplicitContent() |
81
|
|
|
{ |
82
|
|
|
return $this->expicitContent; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
protected function getComponent() |
86
|
|
|
{ |
87
|
|
|
$component = new \stdClass(); |
88
|
|
|
$component->url = $this->getUrl(); |
89
|
|
|
$component->role = $this->getRole(); |
90
|
|
|
$component->aspectRatio = $this->getAspectRatio(); |
91
|
|
|
$component->caption = $this->getCaption(); |
92
|
|
|
$component->accessibilityCaption = $this->getAccessibilityCaption(); |
93
|
|
|
$component->expicitContent = $this->getExplicitContent(); |
94
|
|
|
return $component; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|