1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* this file is part of pipelines */ |
4
|
|
|
|
5
|
|
|
namespace Ktomk\Pipelines\Runner; |
6
|
|
|
|
7
|
|
|
use Ktomk\Pipelines\Utility\Options; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Runner options parameter object |
11
|
|
|
*/ |
12
|
|
|
class RunOpts |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
private $prefix; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var Options |
21
|
|
|
*/ |
22
|
|
|
private $options; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $binaryPackage; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Static factory method |
31
|
|
|
* |
32
|
|
|
* @param string $prefix [optional] |
33
|
|
|
* @param string $binaryPackage package name or path to binary (string) |
34
|
|
|
* |
35
|
|
|
* @return RunOpts |
36
|
|
|
*/ |
37
|
1 |
|
public static function create($prefix = null, $binaryPackage = null) |
38
|
|
|
{ |
39
|
1 |
|
return new self($prefix, Options::create(), $binaryPackage); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* RunOpts constructor. |
44
|
|
|
* |
45
|
|
|
* NOTE: All run options are optional by design (pass NULL). |
46
|
|
|
* |
47
|
|
|
* @param string $prefix |
48
|
|
|
* @param null|Options $options |
49
|
|
|
* @param string $binaryPackage package name or path to binary (string) |
50
|
|
|
*/ |
51
|
2 |
|
public function __construct($prefix = null, Options $options = null, $binaryPackage = null) |
52
|
|
|
{ |
53
|
2 |
|
$this->prefix = $prefix; |
54
|
2 |
|
$this->options = $options; |
55
|
2 |
|
$this->binaryPackage = $binaryPackage; |
56
|
2 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $prefix |
60
|
|
|
*/ |
61
|
1 |
|
public function setPrefix($prefix) |
62
|
|
|
{ |
63
|
1 |
|
$this->prefix = $prefix; |
64
|
1 |
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* The prefix is used when creating containers for the container name. |
68
|
|
|
* |
69
|
|
|
* See --prefix option. |
70
|
|
|
* |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
1 |
|
public function getPrefix() |
74
|
|
|
{ |
75
|
1 |
|
return $this->prefix; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param string $name |
80
|
|
|
* |
81
|
|
|
* @return null|string |
82
|
|
|
*/ |
83
|
2 |
|
public function getOption($name) |
84
|
|
|
{ |
85
|
2 |
|
if (!isset($this->options)) { |
86
|
1 |
|
return null; |
87
|
|
|
} |
88
|
|
|
|
89
|
1 |
|
return $this->options->get($name); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param string $binaryPackage |
94
|
|
|
*/ |
95
|
1 |
|
public function setBinaryPackage($binaryPackage) |
96
|
|
|
{ |
97
|
1 |
|
$this->binaryPackage = $binaryPackage; |
98
|
1 |
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return string |
102
|
|
|
*/ |
103
|
1 |
|
public function getBinaryPackage() |
104
|
|
|
{ |
105
|
1 |
|
return $this->binaryPackage; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|