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

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