FlickRFinder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A find() 0 13 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WebThumbnailer\Finder;
6
7
/**
8
 * Finder for flickr.com. Works with the homepage, profiles and picture page.
9
 *
10
 * Apply size parameter on thumb URL.
11
 *
12
 * @see QueryRegexFinder for more info.
13
 */
14
class FlickRFinder extends QueryRegexFinder
15
{
16
    /**
17
     * FlickR image permalinks are suffixed by a size character.
18
     * This finder will replace it according to user size settings.
19
     *
20
     * @inheritdoc
21
     */
22
    public function find()
23
    {
24
        $thumb = parent::find();
25
        if (empty($thumb)) {
26
            return false;
27
        }
28
29
        $size = $this->getOptionValue('size');
30
        // One size is actually no suffix...
31
        $size = ! empty($size) ? '_' . $size : '';
32
        $thumb = preg_replace('#(.*)_\w(\.\w+)$#i', '$1' . $size . '$2', $thumb);
33
34
        return $thumb ?? false;
35
    }
36
}
37