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

PresetLoader::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
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