1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/* |
3
|
|
|
* This file is part of the feed-io package. |
4
|
|
|
* |
5
|
|
|
* (c) Alexandre Debril <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace FeedIo\Feed\Item; |
12
|
|
|
|
13
|
|
|
use FeedIo\Feed\ArrayableInterface; |
14
|
|
|
|
15
|
|
|
class Media implements MediaInterface, ArrayableInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected $nodeName; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $type; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
protected $url; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $length; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
protected $title; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
protected $description; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
protected $thumbnail; |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return string |
55
|
|
|
*/ |
56
|
|
|
public function getNodeName() : ? string |
57
|
|
|
{ |
58
|
|
|
return $this->nodeName; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param string $nodeName |
63
|
|
|
* @return MediaInterface |
64
|
|
|
*/ |
65
|
5 |
|
public function setNodeName(string $nodeName) : MediaInterface |
66
|
|
|
{ |
67
|
5 |
|
$this->nodeName = $nodeName; |
68
|
|
|
|
69
|
5 |
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @deprecated |
74
|
|
|
* @return bool |
75
|
|
|
*/ |
76
|
|
|
public function isThumbnail() : bool |
77
|
|
|
{ |
78
|
|
|
trigger_error('Method isThumbnail is deprecated and will be removed in feed-io 5.0', E_USER_DEPRECATED); |
79
|
|
|
return $this->nodeName === 'media:thumbnail'; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return string |
84
|
|
|
*/ |
85
|
5 |
|
public function getType() : ? string |
86
|
|
|
{ |
87
|
5 |
|
return $this->type; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param string $type |
92
|
|
|
* @return MediaInterface |
93
|
|
|
*/ |
94
|
8 |
|
public function setType(?string $type) : MediaInterface |
95
|
|
|
{ |
96
|
8 |
|
$this->type = $type; |
97
|
|
|
|
98
|
8 |
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return string |
103
|
|
|
*/ |
104
|
7 |
|
public function getUrl() : ? string |
105
|
|
|
{ |
106
|
7 |
|
return $this->url; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param string $url |
111
|
|
|
* @return MediaInterface |
112
|
|
|
*/ |
113
|
8 |
|
public function setUrl(?string $url) : MediaInterface |
114
|
|
|
{ |
115
|
8 |
|
$this->url = $url; |
116
|
|
|
|
117
|
8 |
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return string |
122
|
|
|
*/ |
123
|
3 |
|
public function getLength() : ? string |
124
|
|
|
{ |
125
|
3 |
|
return $this->length; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param string $length |
130
|
|
|
* @return MediaInterface |
131
|
|
|
*/ |
132
|
6 |
|
public function setLength(?string $length) : MediaInterface |
133
|
|
|
{ |
134
|
6 |
|
$this->length = $length; |
135
|
|
|
|
136
|
6 |
|
return $this; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return string |
142
|
|
|
*/ |
143
|
1 |
|
public function getTitle() : ? string |
144
|
|
|
{ |
145
|
1 |
|
return $this->title; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param string $title |
150
|
|
|
* @return MediaInterface |
151
|
|
|
*/ |
152
|
2 |
|
public function setTitle(?string $title) : MediaInterface |
153
|
|
|
{ |
154
|
2 |
|
$this->title = $title; |
155
|
|
|
|
156
|
2 |
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @return string |
161
|
|
|
*/ |
162
|
1 |
|
public function getDescription() : ? string |
163
|
|
|
{ |
164
|
1 |
|
return $this->description; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @param string $description |
169
|
|
|
* @return MediaInterface |
170
|
|
|
*/ |
171
|
1 |
|
public function setDescription(?string $description) : MediaInterface |
172
|
|
|
{ |
173
|
1 |
|
$this->description = $description; |
174
|
|
|
|
175
|
1 |
|
return $this; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @return string |
180
|
|
|
*/ |
181
|
1 |
|
public function getThumbnail() : ? string |
182
|
|
|
{ |
183
|
1 |
|
return $this->thumbnail; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param string $thumbnail |
188
|
|
|
* @return MediaInterface |
189
|
|
|
*/ |
190
|
1 |
|
public function setThumbnail(?string $thumbnail) : MediaInterface |
191
|
|
|
{ |
192
|
1 |
|
$this->thumbnail = $thumbnail; |
193
|
|
|
|
194
|
1 |
|
return $this; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* @return array |
199
|
|
|
*/ |
200
|
1 |
|
public function toArray() : array |
201
|
|
|
{ |
202
|
1 |
|
return get_object_vars($this); |
203
|
|
|
} |
204
|
|
|
} |
205
|
|
|
|