1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Soluble\MediaTools\Common\Process; |
6
|
|
|
|
7
|
|
|
class ProcessParams implements ProcessParamsInterface |
8
|
|
|
{ |
9
|
|
|
public const DEFAULT_TIMEOUT = null; |
10
|
|
|
public const DEFAULT_IDLE_TIMEOUT = null; |
11
|
|
|
public const DEFAULT_ENV = []; |
12
|
|
|
|
13
|
|
|
/** @var float|null */ |
14
|
|
|
protected $timeout; |
15
|
|
|
|
16
|
|
|
/** @var float|null */ |
17
|
|
|
protected $idleTimeout; |
18
|
|
|
|
19
|
|
|
/** @var array<string, string|int> */ |
20
|
|
|
protected $env; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param float|null $timeout max allowed time (in seconds) for symfony process |
24
|
|
|
* @param float|null $idleTimeout max allowed idle time (in seconds) for symfony process |
25
|
|
|
* @param array<string, string|int> $env An array of additional env vars to set when running the symfony process |
26
|
|
|
*/ |
27
|
42 |
|
public function __construct( |
28
|
|
|
?float $timeout = self::DEFAULT_TIMEOUT, |
29
|
|
|
?float $idleTimeout = self::DEFAULT_IDLE_TIMEOUT, |
30
|
|
|
array $env = self::DEFAULT_ENV |
31
|
|
|
) { |
32
|
42 |
|
$this->timeout = $timeout; |
33
|
42 |
|
$this->idleTimeout = $idleTimeout; |
34
|
42 |
|
$this->env = $env; |
35
|
42 |
|
} |
36
|
|
|
|
37
|
22 |
|
public function getTimeout(): ?float |
38
|
|
|
{ |
39
|
22 |
|
return $this->timeout; |
40
|
|
|
} |
41
|
|
|
|
42
|
1 |
|
public function setTimeout(?float $timeout): void |
43
|
|
|
{ |
44
|
1 |
|
$this->timeout = $timeout; |
45
|
1 |
|
} |
46
|
|
|
|
47
|
22 |
|
public function getIdleTimeout(): ?float |
48
|
|
|
{ |
49
|
22 |
|
return $this->idleTimeout; |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
public function setIdleTimeout(?float $idleTimeout): void |
53
|
|
|
{ |
54
|
1 |
|
$this->idleTimeout = $idleTimeout; |
55
|
1 |
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return array<string, string|int> |
59
|
|
|
*/ |
60
|
22 |
|
public function getEnv(): array |
61
|
|
|
{ |
62
|
22 |
|
return $this->env; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param array<string, string|int> $env |
67
|
|
|
*/ |
68
|
1 |
|
public function setEnv(array $env): void |
69
|
|
|
{ |
70
|
1 |
|
$this->env = $env; |
71
|
1 |
|
} |
72
|
|
|
} |
73
|
|
|
|