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