Completed
Push — master ( 359fe7...152344 )
by Sébastien
03:49
created

PresetLoader::getPreset()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\MediaTools\Preset;
6
7
use Psr\Container\ContainerInterface;
8
use Soluble\MediaTools\Cli\Exception\UnknownPresetException;
9
10
class PresetLoader
11
{
12
    /**
13
     * @var PresetLocator
14
     */
15
    private $locator;
16
17
    /**
18
     * @var ContainerInterface
19
     */
20
    private $container;
21
22 2
    public function __construct(PresetLocator $locator, ContainerInterface $container)
23
    {
24 2
        $this->locator   = $locator;
25 2
        $this->container = $container;
26 2
    }
27
28
    public function getPreset(string $presetName): PresetInterface
29
    {
30
        if (!$this->locator->isSupported($presetName)) {
31
            throw new UnknownPresetException(sprintf('Preset %s does not exists', $presetName));
32
        }
33
34
        return $this->container->get($presetName);
35
    }
36
}
37