Completed
Push — master ( 070a7f...5725b1 )
by Sébastien
04:16
created

FFProbeConfig::getProcess()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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