DownscaleFilterLoader   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 17
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1
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
/*
4
 * This file is part of the `liip/LiipImagineBundle` project.
5
 *
6
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Liip\ImagineBundle\Imagine\Filter\Loader;
13
14
/**
15
 * Downscale filter.
16
 *
17
 * @author Devi Prasad <https://github.com/deviprsd21>
18
 */
19
class DownscaleFilterLoader extends ScaleFilterLoader
20
{
21
    public function __construct()
22
    {
23
        parent::__construct('max', 'by', false);
24
    }
25
26
    protected function calcAbsoluteRatio($ratio)
27
    {
28
        return 1 - ($ratio > 1 ? $ratio - floor($ratio) : $ratio);
29
    }
30
31
    protected function isImageProcessable($ratio)
32
    {
33
        return $ratio < 1;
34
    }
35
}
36