HasSrcSet   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 25
ccs 12
cts 12
cp 1
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A srcsetMap() 0 20 5
1
<?php
2
3
namespace SimpleImageManager\Managers;
4
5
trait HasSrcSet
6
{
7
    /**
8
     * @inheritDoc
9
     */
10 1
    public function srcsetMap(): array
11
    {
12 1
        $map = [];
13
14 1
        if (is_array($this->original) &&
15 1
            !empty($this->original['srcset'])) {
16 1
            $map[''] = $this->original['srcset'];
17
        }
18
19 1
        foreach ($this->formats as $format => $configuration) {
20 1
            if (!empty($configuration['srcset'])) {
21 1
                $map[$format] = $configuration['srcset'];
22
            }
23
        }
24
25 1
        uasort($map, function ($a, $b) {
26 1
            return (int)$b - (int)$a;
27 1
        });
28
29 1
        return $map;
30
    }
31
}
32