PasteFilterLoader::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 2
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\Image\ImageInterface;
15
use Imagine\Image\ImagineInterface;
16
use Imagine\Image\Point;
17
18
class PasteFilterLoader implements LoaderInterface
19
{
20
    /**
21
     * @var ImagineInterface
22
     */
23
    protected $imagine;
24
25
    /**
26
     * @var string
27
     */
28
    protected $projectDir;
29
30
    public function __construct(ImagineInterface $imagine, $projectDir)
31
    {
32
        $this->imagine = $imagine;
33
        $this->projectDir = $projectDir;
34
    }
35
36
    /**
37
     * @see \Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface::load()
38
     *
39
     * @return ImageInterface|static
40
     */
41
    public function load(ImageInterface $image, array $options = [])
42
    {
43
        $x = isset($options['start'][0]) ? $options['start'][0] : null;
44
        $y = isset($options['start'][1]) ? $options['start'][1] : null;
45
46
        $destImage = $this->imagine->open($this->projectDir.'/'.$options['image']);
47
48
        return $image->paste($destImage, new Point($x, $y));
49
    }
50
}
51