Passed
Push — master ( 4744e0...bd9fc8 )
by Sébastien
02:34
created

FFMpegConfigFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 23
ccs 8
cts 12
cp 0.6667
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 18 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 FFMpegConfigFactory
11
{
12
    /**
13
     * @throws InvalidConfigException
14
     */
15 1
    public function __invoke(ContainerInterface $container): FFMpegConfig
16
    {
17 1
        $key    = 'ffmpeg.binary';
18 1
        $config = $container->get('config')['soluble-mediatools'] ?? [];
19
20 1
        if (!isset($config[$key]) || trim((string) $config[$key]) === '') {
21
            throw new InvalidConfigException(
22
                sprintf(
23
                    'The [\'%s\'] value is missing in config [\'soluble-mediatools\']',
24
                    $key
25
                )
26
            );
27
        }
28 1
        $threads     = $config['ffmpeg.conversion.threads'] ?? null;
29 1
        $timeout     = $config['ffmpeg.conversion.timeout'] ?? null;
30 1
        $idleTimeout = $config['ffmpeg.conversion.idle_timeout'] ?? null;
31
32 1
        return new FFMpegConfig($config[$key], $threads, $timeout, $idleTimeout);
33
    }
34
}
35