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

FilterPathContainer::getTarget()   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
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\Service;
13
14
final class FilterPathContainer
15
{
16
    /**
17
     * @var string
18
     */
19
    private $source;
20
21
    /**
22
     * @var string
23
     */
24
    private $target;
25
26
    /**
27
     * @var mixed[]
28
     */
29
    private $options;
30
31
    /**
32
     * @param string  $source
33
     * @param string  $target
34
     * @param mixed[] $options
35
     */
36
    public function __construct(string $source, string $target = '', array $options = [])
37
    {
38
        $this->source = $source;
39
        $this->target = '' !== $target ? $target : $source;
40
        $this->options = $options;
41
    }
42
43
    /**
44
     * @param array $options
45
     *
46
     * @return self
47
     */
48
    public function createWebp(array $options): self
49
    {
50
        return new self(
51
            $this->source,
52
            $this->target.'.webp',
53
            [
54
                'format' => 'webp',
55
            ] + $options + $this->options
56
        );
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function getSource(): string
63
    {
64
        return $this->source;
65
    }
66
67
    /**
68
     * @return string
69
     */
70
    public function getTarget(): string
71
    {
72
        return $this->target;
73
    }
74
75
    /**
76
     * @return mixed[]
77
     */
78
    public function getOptions(): array
79
    {
80
        return $this->options;
81
    }
82
}
83