WidthScaler   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B scale() 0 20 7
1
<?php
2
3
namespace Brendt\Image\Scaler;
4
5
use Intervention\Image\Image;
6
use Symfony\Component\Finder\SplFileInfo;
7
8
class WidthScaler extends AbstractScaler
9
{
10
11
    /**
12
     * @param SplFileInfo $sourceFile
13
     * @param Image       $imageObject
14
     *
15
     * @return array
16
     */
17
    public function scale(SplFileInfo $sourceFile, Image $imageObject) : array {
18
        $width = $imageObject->getWidth();
19
        $height = $imageObject->getHeight();
20
        $sizes = [];
21
22
        if ($this->includeSource && (!$this->maxWidth || $width <= $this->maxWidth)) {
23
            $sizes[$width] = $height;
24
        }
25
26
        while ($width >= $this->minWidth) {
27
            $width = floor($width * $this->stepModifier);
28
            $height = floor($height * $this->stepModifier);
29
30
            if (!$this->maxWidth || $width <= $this->maxWidth) {
31
                $sizes[(int) $width] = $height;
32
            }
33
        }
34
35
        return $sizes;
36
    }
37
}
38