Completed
Pull Request — master (#1307)
by Peter
01:39
created

FilterPathContainer::getSource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * This file is part of the `liip/LiipImagineBundle` project.
6
 *
7
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
8
 *
9
 * For the full copyright and license information, please view the LICENSE.md
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Liip\ImagineBundle\Imagine\Filter;
14
15
final class FilterPathContainer
16
{
17
    /**
18
     * @var string
19
     */
20
    private $source;
21
22
    /**
23
     * @var string
24
     */
25
    private $target;
26
27
    /**
28
     * @var mixed[]
29
     */
30
    private $options;
31
32
    /**
33
     * @param string  $source
34
     * @param string  $target
35
     * @param mixed[] $options
36
     */
37
    public function __construct(string $source, string $target = '', array $options = [])
38
    {
39
        $this->source = $source;
40
        $this->target = '' !== $target ? $target : $source;
41
        $this->options = $options;
42
    }
43
44
    /**
45
     * @param int $quality
46
     *
47
     * @return self
48
     */
49
    public function createWebp(int $quality): self
50
    {
51
        return new self(
52
            $this->source,
53
            $this->target.'.webp',
54
            [
55
                'quality' => $quality,
56
                'format' => 'webp',
57
            ] + $this->options
58
        );
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getSource(): string
65
    {
66
        return $this->source;
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function getTarget(): string
73
    {
74
        return $this->target;
75
    }
76
77
    /**
78
     * @return mixed[]
79
     */
80
    public function getOptions(): array
81
    {
82
        return $this->options;
83
    }
84
}
85