Passed
Push — master ( f99852...46c8e4 )
by Brent
04:34 queued 02:08
created

WidthScaler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

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