@@ -150,15 +150,15 @@ public function __get($name)
150
150
*/
151
151
public function getTitle ()
152
152
{
153
- return Utils::getFirstData ( $ this ->providers , 'title ' ) ?: $ this ->request ->url ->getUrl ();
153
+ return Utils::getFirstValue (Utils:: getData ( $ this ->providers , 'title ' ) ) ?: $ this ->request ->url ->getUrl ();
154
154
}
155
155
156
156
/**
157
157
* {@inheritdoc}
158
158
*/
159
159
public function getDescription ()
160
160
{
161
- return Utils::getFirstData ( $ this ->providers , 'description ' );
161
+ return Utils::getFirstValue (Utils:: getData ( $ this ->providers , 'description ' ) );
162
162
}
163
163
164
164
/**
@@ -172,7 +172,7 @@ public function getType()
172
172
return 'video ' ;
173
173
}
174
174
175
- if (($ type = Utils::getMostPopular (Utils::getAllData ($ this ->providers , 'type ' ))) && ($ type !== 'link ' )) {
175
+ if (($ type = Utils::getMostPopularValue (Utils::getData ($ this ->providers , 'type ' ))) && ($ type !== 'link ' )) {
176
176
return $ type ;
177
177
}
178
178
@@ -192,15 +192,15 @@ public function getType()
192
192
*/
193
193
public function getSource ()
194
194
{
195
- return Utils::getFirstUrlData ( $ this ->request -> url , $ this -> providers , 'source ' );
195
+ return Utils::getFirstValue (Utils:: getData ( $ this ->providers , 'source ' , $ this -> request -> url ) );
196
196
}
197
197
198
198
/**
199
199
* {@inheritdoc}
200
200
*/
201
201
public function getCode ()
202
202
{
203
- if ($ code = Utils::getFirstData ( $ this ->providers , 'code ' )) {
203
+ if ($ code = Utils::getFirstValue (Utils:: getData ( $ this ->providers , 'code ' ) )) {
204
204
if (strpos ($ code , '</iframe> ' ) !== false ) {
205
205
return preg_replace ('|^.*(<iframe.*</iframe>).*$|Us ' , '$1 ' , $ code );
206
206
}
@@ -222,36 +222,43 @@ public function getCode()
222
222
*/
223
223
public function getUrl ()
224
224
{
225
- return Utils::getFirstUrlData ( $ this ->request -> url , $ this ->providers , ' url ' ) ?: $ this ->request ->url ->getUrl ();
225
+ return Utils::getFirstValue (Utils:: getData ( $ this ->providers , ' url ' , $ this ->request -> url ) ) ?: $ this ->request ->url ->getUrl ();
226
226
}
227
227
228
228
/**
229
229
* {@inheritdoc}
230
230
*/
231
231
public function getAuthorName ()
232
232
{
233
- return Utils::getFirstData ( $ this ->providers , 'authorName ' );
233
+ return Utils::getFirstValue (Utils:: getData ( $ this ->providers , 'authorName ' ) );
234
234
}
235
235
236
236
/**
237
237
* {@inheritdoc}
238
238
*/
239
239
public function getAuthorUrl ()
240
240
{
241
- return Utils::getFirstUrlData ( $ this ->request -> url , $ this -> providers , 'authorUrl ' );
241
+ return Utils::getFirstValue (Utils:: getData ( $ this ->providers , 'authorUrl ' , $ this -> request -> url ) );
242
242
}
243
243
244
244
/**
245
245
* {@inheritdoc}
246
246
*/
247
247
public function getProviderIconsUrls ()
248
248
{
249
- $ icons = Utils::getAllUrlData ($ this ->request -> url , $ this -> providers , 'providerIconsUrls ' );
249
+ $ icons = Utils::getData ($ this ->providers , 'providerIconsUrls ' , $ this -> request -> url );
250
250
251
- $ icons [] = $ this ->request ->url ->getAbsolute ('/favicon.ico ' );
252
- $ icons [] = $ this ->request ->url ->getAbsolute ('/favicon.png ' );
251
+ Utils::unshiftValue ($ icons , [
252
+ 'value ' => $ this ->request ->url ->getAbsolute ('/favicon.ico ' ),
253
+ 'providers ' => ['adapter ' ]
254
+ ]);
253
255
254
- return array_unique ($ icons );
256
+ Utils::unshiftValue ($ icons , [
257
+ 'value ' => $ this ->request ->url ->getAbsolute ('/favicon.png ' ),
258
+ 'providers ' => ['adapter ' ]
259
+ ]);
260
+
261
+ return $ icons ;
255
262
}
256
263
257
264
/**
@@ -268,36 +275,34 @@ public function getProviderIcons()
268
275
public function getProviderIcon ()
269
276
{
270
277
if ($ this ->config ['getBiggerIcon ' ]) {
271
- return Utils::getBiggerImage ($ this ->providerIcons );
272
- }
273
-
274
- if (($ icons = $ this ->providerIcons ) && reset ($ icons )) {
275
- return key ($ icons );
278
+ return Utils::getBiggerValue ($ this ->providerIcons );
276
279
}
280
+
281
+ return Utils::getFirstValue ($ this ->providerIcons );
277
282
}
278
283
279
284
/**
280
285
* {@inheritdoc}
281
286
*/
282
287
public function getProviderName ()
283
288
{
284
- return Utils::getFirstData ( $ this ->providers , 'providerName ' ) ?: $ this ->request ->url ->getDomain ();
289
+ return Utils::getFirstValue (Utils:: getData ( $ this ->providers , 'providerName ' ) ) ?: $ this ->request ->url ->getDomain ();
285
290
}
286
291
287
292
/**
288
293
* {@inheritdoc}
289
294
*/
290
295
public function getProviderUrl ()
291
296
{
292
- return Utils::getFirstUrlData ( $ this ->request -> url , $ this -> providers , 'providerUrl ' ) ?: ($ this ->request ->url ->getScheme ().':// ' .$ this ->request ->url ->getDomain (true ));
297
+ return Utils::getFirstValue (Utils:: getData ( $ this ->providers , 'providerUrl ' , $ this -> request -> url ) ) ?: ($ this ->request ->url ->getScheme ().':// ' .$ this ->request ->url ->getDomain (true ));
293
298
}
294
299
295
300
/**
296
301
* {@inheritdoc}
297
302
*/
298
303
public function getImagesUrls ()
299
304
{
300
- return Utils::getAllUrlData ($ this ->request -> url , $ this -> providers , 'imagesUrls ' );
305
+ return Utils::getData ($ this ->providers , 'imagesUrls ' , $ this -> request -> url );
301
306
}
302
307
303
308
/**
@@ -314,20 +319,24 @@ public function getImages()
314
319
public function getImage ()
315
320
{
316
321
if ($ this ->config ['getBiggerImage ' ]) {
317
- if (($ src = Utils::getBiggerImage ($ this ->images )) ) {
322
+ if (($ src = Utils::getBiggerValue ($ this ->images , true )) !== null ) {
318
323
$ image = $ this ->images [$ src ];
319
324
320
- if (($ image [0 ] >= $ this ->config ['minImageWidth ' ]) && ($ image [1 ] >= $ this ->config ['minImageHeight ' ])) {
325
+ if (($ image [' width ' ] >= $ this ->config ['minImageWidth ' ]) && ($ image [' height ' ] >= $ this ->config ['minImageHeight ' ])) {
321
326
return $ src ;
322
327
}
323
328
}
324
329
325
330
return ;
326
331
}
327
332
328
- foreach ($ this ->images as $ src => $ image ) {
329
- if (($ image [0 ] >= $ this ->config ['minImageWidth ' ]) && ($ image [1 ] >= $ this ->config ['minImageHeight ' ])) {
330
- return $ src ;
333
+ foreach (Utils::sortByProviders ($ this ->images ) as $ images ) {
334
+ if (($ key = Utils::getBiggerValue ($ images , true )) !== null ) {
335
+ $ image = $ this ->images [$ key ];
336
+
337
+ if (($ image ['width ' ] >= $ this ->config ['minImageWidth ' ]) && ($ image ['height ' ] >= $ this ->config ['minImageHeight ' ])) {
338
+ return $ image ['value ' ];
339
+ }
331
340
}
332
341
}
333
342
}
@@ -337,8 +346,8 @@ public function getImage()
337
346
*/
338
347
public function getImageWidth ()
339
348
{
340
- if ($ this ->image ) {
341
- return $ this -> images [ $ this -> image ][ 0 ];
349
+ if (( $ image = Utils:: searchValue ( $ this ->images , $ this -> image )) !== false ) {
350
+ return $ image[ ' width ' ];
342
351
}
343
352
}
344
353
@@ -347,8 +356,8 @@ public function getImageWidth()
347
356
*/
348
357
public function getImageHeight ()
349
358
{
350
- if ($ this ->image ) {
351
- return $ this -> images [ $ this -> image ][ 1 ];
359
+ if (( $ image = Utils:: searchValue ( $ this ->images , $ this -> image )) !== false ) {
360
+ return $ image[ ' height ' ];
352
361
}
353
362
}
354
363
@@ -357,15 +366,15 @@ public function getImageHeight()
357
366
*/
358
367
public function getWidth ()
359
368
{
360
- return Utils::getFirstData ( $ this ->providers , 'width ' );
369
+ return Utils::getFirstValue (Utils:: getData ( $ this ->providers , 'width ' ) );
361
370
}
362
371
363
372
/**
364
373
* {@inheritdoc}
365
374
*/
366
375
public function getHeight ()
367
376
{
368
- return Utils::getFirstData ( $ this ->providers , 'height ' );
377
+ return Utils::getFirstValue (Utils:: getData ( $ this ->providers , 'height ' ) );
369
378
}
370
379
371
380
/**
@@ -386,6 +395,6 @@ public function getAspectRatio()
386
395
*/
387
396
public function getPublishedTime ()
388
397
{
389
- return Utils::getFirstData ( $ this ->providers , 'publishedTime ' );
398
+ return Utils::getFirstValue (Utils:: getData ( $ this ->providers , 'publishedTime ' ) );
390
399
}
391
400
}
0 commit comments