CropFilterLoader   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 13 5
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
use Imagine\Filter\Basic\Crop;
15
use Imagine\Image\Box;
16
use Imagine\Image\ImageInterface;
17
use Imagine\Image\Point;
18
19
class CropFilterLoader implements LoaderInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function load(ImageInterface $image, array $options = [])
25
    {
26
        $x = isset($options['start'][0]) ? $options['start'][0] : null;
27
        $y = isset($options['start'][1]) ? $options['start'][1] : null;
28
29
        $width = isset($options['size'][0]) ? $options['size'][0] : null;
30
        $height = isset($options['size'][1]) ? $options['size'][1] : null;
31
32
        $filter = new Crop(new Point($x, $y), new Box($width, $height));
33
        $image = $filter->apply($image);
34
35
        return $image;
36
    }
37
}
38