Passed
Push — master ( bed015...129377 )
by Sébastien
04:15
created

FFProbeConfig::getProcessParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\MediaTools\Video\Config;
6
7
use Soluble\MediaTools\Common\Process\ProcessParamsInterface;
8
use Soluble\MediaTools\Video\ProcessParams;
9
10
class FFProbeConfig implements FFProbeConfigInterface
11
{
12
    public const DEFAULT_TIMEOUT      = null;
13
    public const DEFAULT_IDLE_TIMEOUT = null;
14
    public const DEFAULT_ENV          = [];
15
16
    /** @var string */
17
    protected $binary;
18
19
    /** @var ProcessParamsInterface */
20
    protected $processParams;
21
22
    /**
23
     * @param string                    $ffprobeBinary FFProbeBinary, if null: 'ffprobe' on linux, 'ffmprobe.exe' on windows
24
     * @param float|null                $timeout       max allowed time (in seconds) for conversion, null for no timeout
25
     * @param float|null                $idleTimeout   max allowed idle time (in seconds) for conversion, null for no timeout
26
     * @param array<string, string|int> $env           An array of additional env vars to set when running the ffprobe process
27
     */
28 7
    public function __construct(
29
        ?string $ffprobeBinary = null,
30
        ?float $timeout = self::DEFAULT_TIMEOUT,
31
        ?float $idleTimeout = self::DEFAULT_IDLE_TIMEOUT,
32
        array $env = self::DEFAULT_ENV
33
    ) {
34 7
        $this->binary = $ffprobeBinary ?? self::getPlatformDefaultBinary();
35
36 7
        $this->processParams = new ProcessParams(
37 7
            $timeout,
38 7
            $idleTimeout,
39 7
            $env
40
        );
41 7
    }
42
43 1
    public static function getPlatformDefaultBinary(): string
44
    {
45 1
        return DIRECTORY_SEPARATOR === '\\' ? 'ffprobe.exe' : 'ffprobe';
46
    }
47
48 6
    public function getBinary(): string
49
    {
50 6
        return $this->binary;
51
    }
52
53 3
    public function getProcessParams(): ProcessParamsInterface
54
    {
55 3
        return $this->processParams;
56
    }
57
}
58