Completed
Push — master ( c2562a...15ecc0 )
by Lukas Kahwe
09:33 queued 06:51
created

CropFilterLoader::load()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 8
nc 16
nop 2
1
<?php
2
3
namespace Liip\ImagineBundle\Imagine\Filter\Loader;
4
5
use Imagine\Filter\Basic\Crop;
6
use Imagine\Image\Box;
7
use Imagine\Image\Point;
8
use Imagine\Image\ImageInterface;
9
10
class CropFilterLoader implements LoaderInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function load(ImageInterface $image, array $options = array())
16
    {
17
        $x = isset($options['start'][0]) ? $options['start'][0] : null;
18
        $y = isset($options['start'][1]) ? $options['start'][1] : null;
19
20
        $width = isset($options['size'][0]) ? $options['size'][0] : null;
21
        $height = isset($options['size'][1]) ? $options['size'][1] : null;
22
23
        $filter = new Crop(new Point($x, $y), new Box($width, $height));
24
        $image = $filter->apply($image);
25
26
        return $image;
27
    }
28
}
29