Completed
Push — master ( 0276fe...fe00d6 )
by Sébastien
02:48
created

FFProbeConfigFactory::__invoke()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 9.7998
c 0
b 0
f 0
cc 3
nc 2
nop 1
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\MediaTools\Config;
6
7
use Psr\Container\ContainerInterface;
8
use Soluble\MediaTools\Exception\InvalidConfigException;
9
10
class FFProbeConfigFactory
11
{
12
    /**
13
     * @throws InvalidConfigException
14
     */
15 6
    public function __invoke(ContainerInterface $container): FFProbeConfig
16
    {
17 6
        $key    = 'ffprobe.binary';
18 6
        $config = $container->get('config')['soluble-mediatools'] ?? [];
19 6
        if (!isset($config[$key]) || trim((string) $config[$key]) === '') {
20 2
            throw new InvalidConfigException(
21 2
                sprintf(
22 2
                    'The [\'%s\'] value is missing in config [\'soluble-mediatools\']',
23 2
                    $key
24
                )
25
            );
26
        }
27
28 4
        return new FFProbeConfig($config[$key]);
29
    }
30
}
31