Completed
Push — master ( 170f19...bdd819 )
by Sébastien
02:34
created

FFMpegConfig::getProcess()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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