Completed
Push — master ( 319645...655917 )
by Lukas Kahwe
14s
created

DownscaleFilterLoader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 4
c 4
b 1
f 0
lcom 0
cbo 1
dl 0
loc 17
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A calcAbsoluteRatio() 0 4 2
A isImageProcessable() 0 4 1
1
<?php
2
3
namespace Liip\ImagineBundle\Imagine\Filter\Loader;
4
5
/**
6
 * Downscale filter.
7
 *
8
 * @author Devi Prasad <https://github.com/deviprsd21>
9
 */
10
class DownscaleFilterLoader extends ScaleFilterLoader
11
{
12
    public function __construct()
13
    {
14
        parent::__construct('max', 'by', false);
15
    }
16
17
    protected function calcAbsoluteRatio($ratio)
18
    {
19
        return 1 - ($ratio > 1 ? $ratio - floor($ratio) : $ratio);
20
    }
21
22
    protected function isImageProcessable($ratio)
23
    {
24
        return $ratio < 1;
25
    }
26
}
27