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
|
|
|
* @var null|string of step expression or null if not set |
31
|
|
|
*/ |
32
|
|
|
private $steps; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var bool |
36
|
|
|
*/ |
37
|
|
|
private $noManual = false; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Static factory method |
41
|
|
|
* |
42
|
|
|
* @param string $prefix [optional] |
43
|
|
|
* @param string $binaryPackage package name or path to binary (string) |
44
|
|
|
* |
45
|
|
|
* @return RunOpts |
46
|
|
|
*/ |
47
|
1 |
|
public static function create($prefix = null, $binaryPackage = null) |
48
|
|
|
{ |
49
|
1 |
|
return new self($prefix, Options::create(), $binaryPackage); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* RunOpts constructor. |
54
|
|
|
* |
55
|
|
|
* NOTE: All run options are optional by design (pass NULL). |
56
|
|
|
* |
57
|
|
|
* @param string $prefix |
58
|
|
|
* @param null|Options $options |
59
|
|
|
* @param string $binaryPackage package name or path to binary (string) |
60
|
|
|
*/ |
61
|
2 |
|
public function __construct($prefix = null, Options $options = null, $binaryPackage = null) |
62
|
|
|
{ |
63
|
2 |
|
$this->prefix = $prefix; |
64
|
2 |
|
$this->options = $options; |
65
|
2 |
|
$this->binaryPackage = $binaryPackage; |
66
|
2 |
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param string $prefix |
70
|
|
|
*/ |
71
|
1 |
|
public function setPrefix($prefix) |
72
|
|
|
{ |
73
|
1 |
|
$this->prefix = $prefix; |
74
|
1 |
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* The prefix is used when creating containers for the container name. |
78
|
|
|
* |
79
|
|
|
* See --prefix option. |
80
|
|
|
* |
81
|
|
|
* @return string |
82
|
|
|
*/ |
83
|
1 |
|
public function getPrefix() |
84
|
|
|
{ |
85
|
1 |
|
return $this->prefix; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param string $name |
90
|
|
|
* |
91
|
|
|
* @return null|string |
92
|
|
|
*/ |
93
|
2 |
|
public function getOption($name) |
94
|
|
|
{ |
95
|
2 |
|
if (!isset($this->options)) { |
96
|
1 |
|
return null; |
97
|
|
|
} |
98
|
|
|
|
99
|
1 |
|
return $this->options->get($name); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param string $binaryPackage |
104
|
|
|
*/ |
105
|
1 |
|
public function setBinaryPackage($binaryPackage) |
106
|
|
|
{ |
107
|
1 |
|
$this->binaryPackage = $binaryPackage; |
108
|
1 |
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return string |
112
|
|
|
*/ |
113
|
1 |
|
public function getBinaryPackage() |
114
|
|
|
{ |
115
|
1 |
|
return $this->binaryPackage; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return null|string |
120
|
|
|
*/ |
121
|
1 |
|
public function getSteps() |
122
|
|
|
{ |
123
|
1 |
|
return $this->steps; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param null|string $steps |
128
|
|
|
*/ |
129
|
1 |
|
public function setSteps($steps) |
130
|
|
|
{ |
131
|
1 |
|
$this->steps = $steps; |
132
|
1 |
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return bool |
136
|
|
|
*/ |
137
|
1 |
|
public function isNoManual() |
138
|
|
|
{ |
139
|
1 |
|
return $this->noManual; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param bool $noManual |
144
|
|
|
*/ |
145
|
1 |
|
public function setNoManual($noManual) |
146
|
|
|
{ |
147
|
1 |
|
$this->noManual = (bool)$noManual; |
148
|
1 |
|
} |
149
|
|
|
} |
150
|
|
|
|