@@ -151,15 +151,15 @@ public function __get($name)
151151 */
152152 public function getTitle ()
153153 {
154- return Utils::getData ($ this ->providers , 'title ' ) ?: $ this ->request ->url ->getUrl ();
154+ return Utils::getFirstData ($ this ->providers , 'title ' ) ?: $ this ->request ->url ->getUrl ();
155155 }
156156
157157 /**
158158 * {@inheritdoc}
159159 */
160160 public function getDescription ()
161161 {
162- return Utils::getData ($ this ->providers , 'description ' );
162+ return Utils::getFirstData ($ this ->providers , 'description ' );
163163 }
164164
165165 /**
@@ -173,7 +173,7 @@ public function getType()
173173 return 'video ' ;
174174 }
175175
176- if (($ type = Utils::getData ( $ this ->providers , 'type ' , false )) && ($ type !== 'link ' )) {
176+ if (($ type = Utils::getMostPopular (Utils:: getAllData ( $ this ->providers , 'type ' ) )) && ($ type !== 'link ' )) {
177177 return $ type ;
178178 }
179179
@@ -193,17 +193,15 @@ public function getType()
193193 */
194194 public function getSource ()
195195 {
196- if (($ source = Utils::getData ($ this ->providers , 'source ' , true ))) {
197- return $ this ->request ->url ->getAbsolute ($ source );
198- }
196+ return Utils::getFirstUrlData ($ this ->request ->url , $ this ->providers , 'source ' );
199197 }
200198
201199 /**
202200 * {@inheritdoc}
203201 */
204202 public function getCode ()
205203 {
206- if ($ code = Utils::getData ($ this ->providers , 'code ' )) {
204+ if ($ code = Utils::getFirstData ($ this ->providers , 'code ' )) {
207205 if (strpos ($ code , '</iframe> ' ) !== false ) {
208206 return preg_replace ('|^.*(<iframe.*</iframe>).*$|Us ' , '$1 ' , $ code );
209207 }
@@ -225,48 +223,44 @@ public function getCode()
225223 */
226224 public function getUrl ()
227225 {
228- if (($ url = Utils::getData ($ this ->providers , 'url ' , true ))) {
229- return $ this ->request ->url ->getAbsolute ($ url );
230- }
231-
232- return $ this ->request ->url ->getUrl ();
226+ return Utils::getFirstUrlData ($ this ->request ->url , $ this ->providers , 'url ' ) ?: $ this ->request ->url ->getUrl ();
233227 }
234228
235229 /**
236230 * {@inheritdoc}
237231 */
238232 public function getAuthorName ()
239233 {
240- return Utils::getData ($ this ->providers , 'authorName ' );
234+ return Utils::getFirstData ($ this ->providers , 'authorName ' );
241235 }
242236
243237 /**
244238 * {@inheritdoc}
245239 */
246240 public function getAuthorUrl ()
247241 {
248- if (($ url = Utils::getData ($ this ->providers , 'authorUrl ' , true ))) {
249- return $ this ->request ->url ->getAbsolute ($ url );
250- }
242+ return Utils::getFirstUrlData ($ this ->request ->url , $ this ->providers , 'authorUrl ' );
251243 }
252244
253245 /**
254246 * {@inheritdoc}
255247 */
256- public function getProviderIcons ()
248+ public function getProviderIconsUrls ()
257249 {
258- $ icons = [];
259-
260- foreach ($ this ->getAllProviders () as $ provider ) {
261- foreach ($ provider ->getProviderIcons () as $ icon ) {
262- $ icons [] = $ this ->request ->url ->getAbsolute ($ icon );
263- }
264- }
250+ $ icons = Utils::getAllUrlData ($ this ->request ->url , $ this ->providers , 'providerIconsUrls ' );
265251
266252 $ icons [] = $ this ->request ->url ->getAbsolute ('/favicon.ico ' );
267253 $ icons [] = $ this ->request ->url ->getAbsolute ('/favicon.png ' );
268254
269- return call_user_func ("{$ this ->imageClass }::getImagesInfo " , array_unique ($ icons ), $ this ->imageConfig );
255+ return array_unique ($ icons );
256+ }
257+
258+ /**
259+ * {@inheritdoc}
260+ */
261+ public function getProviderIcons ()
262+ {
263+ return call_user_func ("{$ this ->imageClass }::getImagesInfo " , $ this ->getProviderIconsUrls ());
270264 }
271265
272266 /**
@@ -288,35 +282,31 @@ public function getProviderIcon()
288282 */
289283 public function getProviderName ()
290284 {
291- return Utils::getData ($ this ->providers , 'providerName ' ) ?: $ this ->request ->url ->getDomain ();
285+ return Utils::getFirstData ($ this ->providers , 'providerName ' ) ?: $ this ->request ->url ->getDomain ();
292286 }
293287
294288 /**
295289 * {@inheritdoc}
296290 */
297291 public function getProviderUrl ()
298292 {
299- if (($ url = Utils::getData ($ this ->providers , 'providerUrl ' , true ))) {
300- return $ this ->request ->url ->getAbsolute ($ url );
301- }
293+ return Utils::getFirstUrlData ($ this ->request ->url , $ this ->providers , 'providerUrl ' ) ?: ($ this ->request ->url ->getScheme ().':// ' .$ this ->request ->url ->getDomain (true ));
294+ }
302295
303- return ($ this ->request ->url ->getScheme ().':// ' .$ this ->request ->url ->getDomain (true ));
296+ /**
297+ * {@inheritdoc}
298+ */
299+ public function getImagesUrls ()
300+ {
301+ return Utils::getAllUrlData ($ this ->request ->url , $ this ->providers , 'imagesUrls ' );
304302 }
305303
306304 /**
307305 * {@inheritdoc}
308306 */
309307 public function getImages ()
310308 {
311- $ images = [];
312-
313- foreach ($ this ->getAllProviders () as $ k => $ provider ) {
314- foreach ($ provider ->getImages () as $ image ) {
315- $ images [] = $ this ->request ->url ->getAbsolute ($ image );
316- }
317- }
318-
319- return call_user_func ("{$ this ->imageClass }::getImagesInfo " , array_unique ($ images ), $ this ->imageConfig );
309+ return call_user_func ("{$ this ->imageClass }::getImagesInfo " , $ this ->getImagesUrls (), $ this ->imageConfig );
320310 }
321311
322312 /**
@@ -368,15 +358,15 @@ public function getImageHeight()
368358 */
369359 public function getWidth ()
370360 {
371- return Utils::getData ($ this ->providers , 'width ' );
361+ return Utils::getFirstData ($ this ->providers , 'width ' );
372362 }
373363
374364 /**
375365 * {@inheritdoc}
376366 */
377367 public function getHeight ()
378368 {
379- return Utils::getData ($ this ->providers , 'height ' );
369+ return Utils::getFirstData ($ this ->providers , 'height ' );
380370 }
381371
382372 /**
@@ -397,6 +387,6 @@ public function getAspectRatio()
397387 */
398388 public function getPublishedTime ()
399389 {
400- return Utils::getData ($ this ->providers , 'publishedTime ' );
390+ return Utils::getFirstData ($ this ->providers , 'publishedTime ' );
401391 }
402392}
0 commit comments