Repository navigation
Expand file tree
/
Copy pathShellTask.php
More file actions
104 lines (87 loc) · 2.54 KB
/
Copy pathShellTask.php
File metadata and controls
104 lines (87 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
declare(strict_types=1);
namespace SchedulerBundle\Task;
use function array_merge;
use function is_array;
use function is_float;
use function is_string;
/**
* @author Guillaume Loulier <contact@guillaumeloulier.fr>
*/
final class ShellTask extends AbstractTask
{
/**
* @param array<int, string> $command
* @param array<string, string> $environmentVariables
* @param array<string, mixed> $options {@see AbstractTask::defineOptions()}
*/
public function __construct(
string $name,
array $command,
?string $cwd = null,
array $environmentVariables = [],
float $timeout = 60.0,
array $options = []
) {
$this->defineOptions(options: array_merge([
'command' => $command,
'cwd' => $cwd,
'environment_variables' => $environmentVariables,
'timeout' => $timeout,
], $options), additionalOptions: [
'command' => 'string[]',
'cwd' => ['string', 'null'],
'environment_variables' => 'string[]',
'timeout' => 'float',
]);
parent::__construct(name: $name);
}
/**
* @return array<int, string>
*/
public function getCommand(): array
{
return is_array(value: $this->options['command']) ? $this->options['command'] : [];
}
/**
* @param array<int, string> $command
*/
public function setCommand(array $command): self
{
$this->options['command'] = $command;
return $this;
}
public function getCwd(): ?string
{
return is_string(value: $this->options['cwd']) ? $this->options['cwd'] : null;
}
public function setCwd(?string $cwd): self
{
$this->options['cwd'] = $cwd;
return $this;
}
/**
* @return array<string, string>
*/
public function getEnvironmentVariables(): array
{
return is_array(value: $this->options['environment_variables']) ? $this->options['environment_variables'] : [];
}
/**
* @param array<string, string> $environmentVariables
*/
public function setEnvironmentVariables(array $environmentVariables): self
{
$this->options['environment_variables'] = $environmentVariables;
return $this;
}
public function getTimeout(): ?float
{
return is_float(value: $this->options['timeout']) ? $this->options['timeout'] : null;
}
public function setTimeout(float $timeout): self
{
$this->options['timeout'] = $timeout;
return $this;
}
}