Failed Conditions
Push — master ( df4f19...50f2bb )
by Sébastien
02:46 queued 13s
created

FFProbeConfigFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 3
eloc 9
dl 0
loc 19
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 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 2
    public function __invoke(ContainerInterface $container): FFProbeConfig
16
    {
17 2
        $key    = 'ffprobe.binary';
18 2
        $config = $container->get('config')['soluble-mediatools'] ?? [];
19 2
        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
        return new FFProbeConfig($config[$key]);
29
    }
30
}
31