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

WidthScaler::scale()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 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