|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Fusonic\OpenGraph\Elements; |
|
4
|
|
|
|
|
5
|
|
|
use Fusonic\OpenGraph\Property; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* An OpenGraph video element. |
|
9
|
|
|
*/ |
|
10
|
|
|
class Video extends ElementBase |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* The URL of a video resource associated with the object. |
|
14
|
|
|
* |
|
15
|
|
|
* @var string |
|
16
|
|
|
*/ |
|
17
|
|
|
public $url; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* An alternate URL to use if a video resource requires HTTPS. |
|
21
|
|
|
* |
|
22
|
|
|
* @var string |
|
23
|
|
|
*/ |
|
24
|
|
|
public $secureUrl; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* The MIME type of a video resource associated with the object. |
|
28
|
|
|
* |
|
29
|
|
|
* @var type |
|
30
|
|
|
*/ |
|
31
|
|
|
public $type; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* The width of a video resource associated with the object in pixels. |
|
35
|
|
|
* |
|
36
|
|
|
* @var int |
|
37
|
|
|
*/ |
|
38
|
|
|
public $width; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* The height of a video resource associated with the object in pixels. |
|
42
|
|
|
* |
|
43
|
|
|
* @var int |
|
44
|
|
|
*/ |
|
45
|
|
|
public $height; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param string $url URL to the video. |
|
49
|
|
|
*/ |
|
50
|
1 |
|
public function __construct($url) |
|
51
|
|
|
{ |
|
52
|
1 |
|
parent::__construct(); |
|
53
|
|
|
|
|
54
|
1 |
|
$this->url = $url; |
|
55
|
1 |
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Gets all properties set on this element. |
|
59
|
|
|
* |
|
60
|
|
|
* @return array|Property[] |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getProperties() |
|
63
|
|
|
{ |
|
64
|
|
|
$properties = []; |
|
65
|
|
|
|
|
66
|
|
|
// URL must precede all other properties |
|
67
|
|
|
if ($this->url !== null) { |
|
68
|
|
|
$properties[] = new Property(Property::VIDEO_URL, $this->url); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
if ($this->height !== null) { |
|
72
|
|
|
$properties[] = new Property(Property::VIDEO_HEIGHT, $this->height); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
if ($this->secureUrl !== null) { |
|
76
|
|
|
$properties[] = new Property(Property::VIDEO_SECURE_URL, $this->secureUrl); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
if ($this->type !== null) { |
|
80
|
|
|
$properties[] = new Property(Property::VIDEO_TYPE, $this->type); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
if ($this->width !== null) { |
|
84
|
|
|
$properties[] = new Property(Property::VIDEO_WIDTH, $this->width); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
return $properties; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|