DownscaleFilterLoader::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
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