1
|
|
|
<?php |
2
|
|
|
namespace SeleniumSetup\Config; |
3
|
|
|
|
4
|
|
|
use SeleniumSetup\Binary\Binary; |
5
|
|
|
|
6
|
|
|
class Config implements ConfigInterface |
7
|
|
|
{ |
8
|
|
|
const DEFAULT_CONFIGURATION_FILENAME = 'default.json'; |
9
|
|
|
|
10
|
|
|
protected $filePath; |
11
|
|
|
protected $name; |
12
|
|
|
protected $hostname; |
13
|
|
|
protected $port; |
14
|
|
|
protected $proxyHost; |
15
|
|
|
protected $proxyPort; |
16
|
|
|
protected $buildPath; |
17
|
|
|
protected $tmpPath; |
18
|
|
|
protected $logsPath; |
19
|
|
|
protected $binaries = []; |
20
|
|
|
|
21
|
|
|
public function toArray() |
22
|
|
|
{ |
23
|
|
|
return get_object_vars($this); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function toJson() |
27
|
|
|
{ |
28
|
|
|
$result = $this->toArray(); |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var integer $index |
32
|
|
|
* @var Binary $binary |
33
|
|
|
*/ |
34
|
|
|
foreach ($this->getBinaries() as $index => $binary) { |
35
|
|
|
$result['binaries'][$index] = $binary->toArray(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
return json_encode($result, JSON_PRETTY_PRINT); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return array |
43
|
|
|
*/ |
44
|
|
|
public static function getAllProperties() |
45
|
|
|
{ |
46
|
|
|
return array_keys(get_object_vars(new self)); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function setFilePath($filePath) |
50
|
|
|
{ |
51
|
|
|
$this->filePath = $filePath; |
52
|
|
|
return $this; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getFilePath() |
56
|
|
|
{ |
57
|
|
|
return $this->filePath; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return mixed |
62
|
|
|
*/ |
63
|
|
|
public function getName() |
64
|
|
|
{ |
65
|
|
|
return $this->name; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param mixed $name |
70
|
|
|
* @return Config |
71
|
|
|
*/ |
72
|
|
|
public function setName($name) |
73
|
|
|
{ |
74
|
|
|
$this->name = $name; |
75
|
|
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
|
|
public function getHostname() |
82
|
|
|
{ |
83
|
|
|
return $this->hostname; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param string $hostname |
88
|
|
|
* @return Config |
89
|
|
|
*/ |
90
|
|
|
public function setHostname($hostname) |
91
|
|
|
{ |
92
|
|
|
$this->hostname = $hostname; |
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return int |
98
|
|
|
*/ |
99
|
|
|
public function getPort() |
100
|
|
|
{ |
101
|
|
|
return $this->port; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param int $port |
106
|
|
|
* @return Config |
107
|
|
|
*/ |
108
|
|
|
public function setPort($port) |
109
|
|
|
{ |
110
|
|
|
$this->port = $port; |
111
|
|
|
return $this; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @return string |
116
|
|
|
*/ |
117
|
|
|
public function getProxyHost() |
118
|
|
|
{ |
119
|
|
|
return $this->proxyHost; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param string $proxyHost |
124
|
|
|
* @return Config |
125
|
|
|
*/ |
126
|
|
|
public function setProxyHost($proxyHost) |
127
|
|
|
{ |
128
|
|
|
$this->proxyHost = $proxyHost; |
129
|
|
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return int |
134
|
|
|
*/ |
135
|
|
|
public function getProxyPort() |
136
|
|
|
{ |
137
|
|
|
return $this->proxyPort; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @param int $proxyPort |
142
|
|
|
* @return Config |
143
|
|
|
*/ |
144
|
|
|
public function setProxyPort($proxyPort) |
145
|
|
|
{ |
146
|
|
|
$this->proxyPort = $proxyPort; |
147
|
|
|
return $this; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return string |
152
|
|
|
*/ |
153
|
|
|
public function getBuildPath() |
154
|
|
|
{ |
155
|
|
|
return $this->buildPath; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @param string $buildPath |
160
|
|
|
* @return Config |
161
|
|
|
*/ |
162
|
|
|
public function setBuildPath($buildPath) |
163
|
|
|
{ |
164
|
|
|
$this->buildPath = $buildPath; |
165
|
|
|
return $this; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @return mixed |
170
|
|
|
*/ |
171
|
|
|
public function getTmpPath() |
172
|
|
|
{ |
173
|
|
|
return $this->tmpPath; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @param mixed $tmpPath |
178
|
|
|
* @return Config |
179
|
|
|
*/ |
180
|
|
|
public function setTmpPath($tmpPath) |
181
|
|
|
{ |
182
|
|
|
$this->tmpPath = $tmpPath; |
183
|
|
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @return string |
188
|
|
|
*/ |
189
|
|
|
public function getLogsPath() |
190
|
|
|
{ |
191
|
|
|
return $this->logsPath; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @param string $logsPath |
196
|
|
|
* @return Config |
197
|
|
|
*/ |
198
|
|
|
public function setLogsPath($logsPath) |
199
|
|
|
{ |
200
|
|
|
$this->logsPath = $logsPath; |
201
|
|
|
return $this; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
public function setBinaries(array $binaries) |
205
|
|
|
{ |
206
|
|
|
$this->binaries = $binaries; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
public function getBinaries() |
210
|
|
|
{ |
211
|
|
|
return $this->binaries; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
public function setBinary($binaryId, Binary $binaryInfo) |
215
|
|
|
{ |
216
|
|
|
$this->binaries[$binaryId] = $binaryInfo; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
public function getBinary($binaryName) |
220
|
|
|
{ |
221
|
|
|
return isset($this->binaries[$binaryName]) ? $this->binaries[$binaryName] : null; |
222
|
|
|
} |
223
|
|
|
} |