Passed
Push — master ( af560c...690258 )
by Sébastien
03:19
created

FFMpegConfig   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 70
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A getIdleTimeout() 0 3 1
A getEnv() 0 3 1
A getThreads() 0 3 1
A getBinary() 0 3 1
A getTimeout() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\MediaTools\Video\Config;
6
7
class FFMpegConfig implements FFMpegConfigInterface
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 float|null */
22
    protected $timeout;
23
24
    /** @var float|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 float|null                $timeout      max allowed time (in seconds) for conversion, null for no timeout
34
     * @param float|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
    public function __construct(
38
        string $ffmpegBinary = self::DEFAULT_BINARY,
39
        ?int $threads = self::DEFAULT_THREADS,
40
        ?float $timeout = self::DEFAULT_TIMEOUT,
41
        ?float $idleTimeout = self::DEFAULT_IDLE_TIMEOUT,
42
        array $env = self::DEFAULT_ENV
43
    ) {
44
        $this->binary      = $ffmpegBinary;
45
        $this->threads     = $threads;
46
        $this->timeout     = $timeout;
47
        $this->idleTimeout = $idleTimeout;
48
        $this->env         = $env;
49
    }
50
51
    public function getBinary(): string
52
    {
53
        return $this->binary;
54
    }
55
56
    public function getThreads(): ?int
57
    {
58
        return $this->threads;
59
    }
60
61
    public function getTimeout(): ?float
62
    {
63
        return $this->timeout;
64
    }
65
66
    public function getIdleTimeout(): ?float
67
    {
68
        return $this->idleTimeout;
69
    }
70
71
    /**
72
     * @return array<string, string|int>
73
     */
74
    public function getEnv(): array
75
    {
76
        return $this->env;
77
    }
78
}
79