1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WsdlToPhp\PackageGenerator\ConfigurationReader; |
4
|
|
|
|
5
|
|
|
class GeneratorOptions extends AbstractYamlReader implements \JsonSerializable |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Common values used as option's value |
9
|
|
|
*/ |
10
|
|
|
const VALUE_CAT = 'cat'; |
11
|
|
|
const VALUE_END = 'end'; |
12
|
|
|
const VALUE_FALSE = false; |
13
|
|
|
const VALUE_NONE = 'none'; |
14
|
|
|
const VALUE_START = 'start'; |
15
|
|
|
const VALUE_TRUE = true; |
16
|
|
|
/** |
17
|
|
|
* Possible option keys |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
const ADD_COMMENTS = 'add_comments'; |
21
|
|
|
const ARRAYS_FOLDER = 'arrays_folder'; |
22
|
|
|
const BASIC_LOGIN = 'basic_login'; |
23
|
|
|
const BASIC_PASSWORD = 'basic_password'; |
24
|
|
|
const CATEGORY = 'category'; |
25
|
|
|
const COMPOSER_NAME = 'composer_name'; |
26
|
|
|
const COMPOSER_SETTINGS = 'composer_settings'; |
27
|
|
|
const DESTINATION = 'destination'; |
28
|
|
|
const ENUMS_FOLDER = 'enums_folder'; |
29
|
|
|
const GATHER_METHODS = 'gather_methods'; |
30
|
|
|
const GENERATE_TUTORIAL_FILE = 'generate_tutorial_file'; |
31
|
|
|
const GENERIC_CONSTANTS_NAME = 'generic_constants_names'; |
32
|
|
|
const NAMESPACE_PREFIX = 'namespace_prefix'; |
33
|
|
|
const ORIGIN = 'origin'; |
34
|
|
|
const PREFIX = 'prefix'; |
35
|
|
|
const PROXY_HOST = 'proxy_host'; |
36
|
|
|
const PROXY_LOGIN = 'proxy_login'; |
37
|
|
|
const PROXY_PASSWORD = 'proxy_password'; |
38
|
|
|
const PROXY_PORT = 'proxy_port'; |
39
|
|
|
const SERVICES_FOLDER = 'services_folder'; |
40
|
|
|
const SOAP_CLIENT_CLASS = 'soap_client_class'; |
41
|
|
|
const SOAP_OPTIONS = 'soap_options'; |
42
|
|
|
const SRC_DIRNAME = 'src_dirname'; |
43
|
|
|
const STANDALONE = 'standalone'; |
44
|
|
|
const STRUCT_ARRAY_CLASS = 'struct_array_class'; |
45
|
|
|
const STRUCT_CLASS = 'struct_class'; |
46
|
|
|
const STRUCTS_FOLDER = 'structs_folder'; |
47
|
|
|
const SUFFIX = 'suffix'; |
48
|
|
|
const VALIDATION = 'validation'; |
49
|
|
|
const SCHEMAS_SAVE = 'schemas_save'; |
50
|
|
|
const SCHEMAS_FOLDER = 'schemas_folder'; |
51
|
|
|
/** |
52
|
|
|
* Generator's options |
53
|
|
|
* @var array |
54
|
|
|
*/ |
55
|
|
|
protected $options; |
56
|
|
|
/** |
57
|
50 |
|
* @param string $filename |
58
|
|
|
*/ |
59
|
50 |
|
protected function __construct($filename) |
60
|
50 |
|
{ |
61
|
45 |
|
$this->options = []; |
62
|
|
|
$this->parseOptions($filename); |
63
|
|
|
} |
64
|
|
|
/** |
65
|
|
|
* Parse options for generator |
66
|
|
|
* @param string $filename options's file to parse |
67
|
50 |
|
* @return GeneratorOptions |
68
|
|
|
*/ |
69
|
50 |
|
protected function parseOptions($filename) |
70
|
50 |
|
{ |
71
|
45 |
|
$options = $this->loadYaml($filename); |
72
|
27 |
|
if (is_array($options)) { |
73
|
5 |
|
$this->options = $options; |
74
|
|
|
} else { |
75
|
45 |
|
throw new \InvalidArgumentException(sprintf('Settings contained by "%s" are not valid as the settings are not contained by an array: "%s"', $filename, gettype($options)), __LINE__); |
76
|
|
|
} |
77
|
|
|
return $this; |
78
|
|
|
} |
79
|
|
|
/** |
80
|
|
|
* Returns the option value |
81
|
|
|
* @throws \InvalidArgumentException |
82
|
|
|
* @param string $optionName |
83
|
1470 |
|
* @return mixed |
84
|
|
|
*/ |
85
|
1470 |
|
public function getOptionValue($optionName) |
86
|
5 |
|
{ |
87
|
|
|
if (!isset($this->options[$optionName])) { |
88
|
1465 |
|
throw new \InvalidArgumentException(sprintf('Invalid option name "%s", possible options: %s', $optionName, implode(', ', array_keys($this->options))), __LINE__); |
89
|
|
|
} |
90
|
|
|
return array_key_exists('value', $this->options[$optionName]) ? $this->options[$optionName]['value'] : $this->options[$optionName]['default']; |
91
|
|
|
} |
92
|
|
|
/** |
93
|
|
|
* Allows to add an option and set its value |
94
|
|
|
* @throws \InvalidArgumentException |
95
|
|
|
* @param string $optionName |
96
|
1120 |
|
* @return GeneratorOptions |
97
|
|
|
*/ |
98
|
1120 |
|
public function setOptionValue($optionName, $optionValue, array $values = []) |
99
|
10 |
|
{ |
100
|
10 |
|
if (!isset($this->options[$optionName])) { |
101
|
10 |
|
$this->options[$optionName] = [ |
102
|
|
|
'value' => $optionValue, |
103
|
1118 |
|
'values' => $values, |
104
|
10 |
|
]; |
105
|
|
|
} elseif (!empty($this->options[$optionName]['values']) && !in_array($optionValue, $this->options[$optionName]['values'], true)) { |
106
|
1105 |
|
throw new \InvalidArgumentException(sprintf('Invalid value "%s" for option "%s", possible values: %s', $optionValue, $optionName, implode(', ', $this->options[$optionName]['values'])), __LINE__); |
107
|
|
|
} else { |
108
|
1110 |
|
$this->options[$optionName]['value'] = $optionValue; |
109
|
|
|
} |
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
/** |
113
|
|
|
* @throws \InvalidArgumentException |
114
|
|
|
* @param string $filename options's file to parse |
115
|
1120 |
|
* @return GeneratorOptions |
116
|
|
|
*/ |
117
|
1120 |
|
public static function instance($filename = null) |
118
|
|
|
{ |
119
|
|
|
return parent::instance(empty($filename) ? self::getDefaultConfigurationPath() : $filename); |
120
|
|
|
} |
121
|
|
|
/** |
122
|
455 |
|
* @return string |
123
|
|
|
*/ |
124
|
455 |
|
public static function getDefaultConfigurationPath() |
125
|
|
|
{ |
126
|
|
|
return __DIR__ . '/../resources/config/generator_options.yml'; |
127
|
|
|
} |
128
|
|
|
/** |
129
|
|
|
* Get category option value |
130
|
405 |
|
* @return string |
131
|
|
|
*/ |
132
|
405 |
|
public function getCategory() |
133
|
|
|
{ |
134
|
|
|
return $this->getOptionValue(self::CATEGORY); |
135
|
|
|
} |
136
|
|
|
/** |
137
|
|
|
* Set current category option value |
138
|
|
|
* @throws \InvalidArgumentException |
139
|
|
|
* @param string $category |
140
|
45 |
|
* @return GeneratorOptions |
141
|
|
|
*/ |
142
|
45 |
|
public function setCategory($category) |
143
|
|
|
{ |
144
|
|
|
return $this->setOptionValue(self::CATEGORY, $category); |
145
|
|
|
} |
146
|
|
|
/** |
147
|
|
|
* Get add comments option value |
148
|
300 |
|
* @return array |
149
|
|
|
*/ |
150
|
300 |
|
public function getAddComments() |
151
|
|
|
{ |
152
|
|
|
return $this->getOptionValue(self::ADD_COMMENTS); |
153
|
|
|
} |
154
|
|
|
/** |
155
|
|
|
* Set current add comments option value |
156
|
|
|
* @throws \InvalidArgumentException |
157
|
|
|
* @param array $addComments |
158
|
95 |
|
* @return GeneratorOptions |
159
|
|
|
*/ |
160
|
|
|
public function setAddComments(array $addComments = []) |
161
|
|
|
{ |
162
|
|
|
/** |
163
|
95 |
|
* If array is type array("author:john Doe","Release:1",) |
164
|
95 |
|
*/ |
165
|
20 |
|
$comments = []; |
166
|
5 |
|
foreach ($addComments as $index => $value) { |
167
|
5 |
|
if (is_numeric($index) && strpos($value, ':') > 0) { |
168
|
3 |
|
list($tag, $val) = explode(':', $value); |
169
|
17 |
|
$comments[$tag] = $val; |
170
|
|
|
} else { |
171
|
57 |
|
$comments[$index] = $value; |
172
|
95 |
|
} |
173
|
|
|
} |
174
|
|
|
return $this->setOptionValue(self::ADD_COMMENTS, $comments); |
175
|
|
|
} |
176
|
|
|
/** |
177
|
|
|
* Get gather methods option value |
178
|
420 |
|
* @return string |
179
|
|
|
*/ |
180
|
420 |
|
public function getGatherMethods() |
181
|
|
|
{ |
182
|
|
|
return $this->getOptionValue(self::GATHER_METHODS); |
183
|
|
|
} |
184
|
|
|
/** |
185
|
|
|
* Set current gather methods option value |
186
|
|
|
* @throws \InvalidArgumentException |
187
|
|
|
* @param string $gatherMethods |
188
|
40 |
|
* @return GeneratorOptions |
189
|
|
|
*/ |
190
|
40 |
|
public function setGatherMethods($gatherMethods) |
191
|
|
|
{ |
192
|
|
|
return $this->setOptionValue(self::GATHER_METHODS, $gatherMethods); |
193
|
|
|
} |
194
|
|
|
/** |
195
|
|
|
* Get generate tutorial file option value |
196
|
50 |
|
* @return bool |
197
|
|
|
*/ |
198
|
50 |
|
public function getGenerateTutorialFile() |
199
|
|
|
{ |
200
|
|
|
return $this->getOptionValue(self::GENERATE_TUTORIAL_FILE); |
201
|
|
|
} |
202
|
|
|
/** |
203
|
|
|
* Set current generate tutorial file option value |
204
|
|
|
* @throws \InvalidArgumentException |
205
|
|
|
* @param bool $generateTutorialFile |
206
|
75 |
|
* @return GeneratorOptions |
207
|
|
|
*/ |
208
|
75 |
|
public function setGenerateTutorialFile($generateTutorialFile) |
209
|
|
|
{ |
210
|
|
|
return $this->setOptionValue(self::GENERATE_TUTORIAL_FILE, $generateTutorialFile); |
211
|
|
|
} |
212
|
|
|
/** |
213
|
|
|
* Get namespace option value |
214
|
375 |
|
* @return string |
215
|
|
|
*/ |
216
|
375 |
|
public function getNamespace() |
217
|
|
|
{ |
218
|
|
|
return $this->getOptionValue(self::NAMESPACE_PREFIX); |
219
|
|
|
} |
220
|
|
|
/** |
221
|
|
|
* Set current namespace option value |
222
|
|
|
* @throws \InvalidArgumentException |
223
|
|
|
* @param string $namespace |
224
|
55 |
|
* @return GeneratorOptions |
225
|
|
|
*/ |
226
|
55 |
|
public function setNamespace($namespace) |
227
|
|
|
{ |
228
|
|
|
return $this->setOptionValue(self::NAMESPACE_PREFIX, $namespace); |
229
|
|
|
} |
230
|
|
|
/** |
231
|
|
|
* Get generic constants name option value |
232
|
90 |
|
* @return bool |
233
|
|
|
*/ |
234
|
90 |
|
public function getGenericConstantsName() |
235
|
|
|
{ |
236
|
|
|
return $this->getOptionValue(self::GENERIC_CONSTANTS_NAME); |
237
|
|
|
} |
238
|
|
|
/** |
239
|
|
|
* Set current generic constants name option value |
240
|
|
|
* @throws \InvalidArgumentException |
241
|
|
|
* @param bool $genericConstantsName |
242
|
75 |
|
* @return GeneratorOptions |
243
|
|
|
*/ |
244
|
75 |
|
public function setGenericConstantsName($genericConstantsName) |
245
|
|
|
{ |
246
|
|
|
return $this->setOptionValue(self::GENERIC_CONSTANTS_NAME, $genericConstantsName); |
247
|
|
|
} |
248
|
|
|
/** |
249
|
|
|
* Get standalone option value |
250
|
95 |
|
* @return bool |
251
|
|
|
*/ |
252
|
95 |
|
public function getStandalone() |
253
|
|
|
{ |
254
|
|
|
return $this->getOptionValue(self::STANDALONE); |
255
|
|
|
} |
256
|
|
|
/** |
257
|
|
|
* Set current standalone option value |
258
|
|
|
* @throws \InvalidArgumentException |
259
|
|
|
* @param bool $standalone |
260
|
45 |
|
* @return GeneratorOptions |
261
|
|
|
*/ |
262
|
45 |
|
public function setStandalone($standalone) |
263
|
|
|
{ |
264
|
|
|
return $this->setOptionValue(self::STANDALONE, $standalone); |
265
|
|
|
} |
266
|
|
|
/** |
267
|
|
|
* Get validation option value |
268
|
175 |
|
* @return bool |
269
|
|
|
*/ |
270
|
175 |
|
public function getValidation() |
271
|
|
|
{ |
272
|
|
|
return $this->getOptionValue(self::VALIDATION); |
273
|
|
|
} |
274
|
|
|
/** |
275
|
|
|
* Set current validation option value |
276
|
|
|
* @throws \InvalidArgumentException |
277
|
|
|
* @param bool $validation |
278
|
40 |
|
* @return GeneratorOptions |
279
|
|
|
*/ |
280
|
40 |
|
public function setValidation($validation) |
281
|
|
|
{ |
282
|
|
|
return $this->setOptionValue(self::VALIDATION, $validation); |
283
|
|
|
} |
284
|
|
|
/** |
285
|
|
|
* Get struct class option value |
286
|
150 |
|
* @return string |
287
|
|
|
*/ |
288
|
150 |
|
public function getStructClass() |
289
|
|
|
{ |
290
|
|
|
return $this->getOptionValue(self::STRUCT_CLASS); |
291
|
|
|
} |
292
|
|
|
/** |
293
|
|
|
* Set current struct class option value |
294
|
|
|
* @throws \InvalidArgumentException |
295
|
|
|
* @param string $structClass |
296
|
45 |
|
* @return GeneratorOptions |
297
|
|
|
*/ |
298
|
45 |
|
public function setStructClass($structClass) |
299
|
|
|
{ |
300
|
|
|
return $this->setOptionValue(self::STRUCT_CLASS, $structClass); |
301
|
|
|
} |
302
|
|
|
/** |
303
|
|
|
* Get struct array class option value |
304
|
60 |
|
* @return string |
305
|
|
|
*/ |
306
|
60 |
|
public function getStructArrayClass() |
307
|
|
|
{ |
308
|
|
|
return $this->getOptionValue(self::STRUCT_ARRAY_CLASS); |
309
|
|
|
} |
310
|
|
|
/** |
311
|
|
|
* Set current struct array class option value |
312
|
|
|
* @throws \InvalidArgumentException |
313
|
|
|
* @param string $structArrayClass |
314
|
35 |
|
* @return GeneratorOptions |
315
|
|
|
*/ |
316
|
35 |
|
public function setStructArrayClass($structArrayClass) |
317
|
|
|
{ |
318
|
|
|
return $this->setOptionValue(self::STRUCT_ARRAY_CLASS, $structArrayClass); |
319
|
|
|
} |
320
|
|
|
/** |
321
|
|
|
* Get struct array class option value |
322
|
135 |
|
* @return string |
323
|
|
|
*/ |
324
|
135 |
|
public function getSoapClientClass() |
325
|
|
|
{ |
326
|
|
|
return $this->getOptionValue(self::SOAP_CLIENT_CLASS); |
327
|
|
|
} |
328
|
|
|
/** |
329
|
|
|
* Set current struct array class option value |
330
|
|
|
* @throws \InvalidArgumentException |
331
|
|
|
* @param string $soapClientClass |
332
|
35 |
|
* @return GeneratorOptions |
333
|
|
|
*/ |
334
|
35 |
|
public function setSoapClientClass($soapClientClass) |
335
|
|
|
{ |
336
|
|
|
return $this->setOptionValue(self::SOAP_CLIENT_CLASS, $soapClientClass); |
337
|
|
|
} |
338
|
|
|
/** |
339
|
|
|
* Get origin option value |
340
|
775 |
|
* @return string |
341
|
|
|
*/ |
342
|
775 |
|
public function getOrigin() |
343
|
|
|
{ |
344
|
|
|
return $this->getOptionValue(self::ORIGIN); |
345
|
|
|
} |
346
|
|
|
/** |
347
|
|
|
* Set current origin option value |
348
|
|
|
* @throws \InvalidArgumentException |
349
|
|
|
* @param string $origin |
350
|
410 |
|
* @return GeneratorOptions |
351
|
|
|
*/ |
352
|
410 |
|
public function setOrigin($origin) |
353
|
|
|
{ |
354
|
|
|
return $this->setOptionValue(self::ORIGIN, $origin); |
355
|
|
|
} |
356
|
|
|
/** |
357
|
|
|
* Get destination option value |
358
|
430 |
|
* @return string |
359
|
|
|
*/ |
360
|
430 |
|
public function getDestination() |
361
|
|
|
{ |
362
|
|
|
return $this->getOptionValue(self::DESTINATION); |
363
|
|
|
} |
364
|
|
|
/** |
365
|
|
|
* Set current destination option value |
366
|
|
|
* @throws \InvalidArgumentException |
367
|
|
|
* @param string $destination |
368
|
415 |
|
* @return GeneratorOptions |
369
|
|
|
*/ |
370
|
415 |
|
public function setDestination($destination) |
371
|
|
|
{ |
372
|
|
|
return $this->setOptionValue(self::DESTINATION, $destination); |
373
|
|
|
} |
374
|
|
|
/** |
375
|
|
|
* Get src dirname option value |
376
|
370 |
|
* @return string |
377
|
|
|
*/ |
378
|
370 |
|
public function getSrcDirname() |
379
|
|
|
{ |
380
|
|
|
return $this->getOptionValue(self::SRC_DIRNAME); |
381
|
|
|
} |
382
|
|
|
/** |
383
|
|
|
* Set current src dirname option value |
384
|
|
|
* @throws \InvalidArgumentException |
385
|
|
|
* @param string $srcDirname |
386
|
25 |
|
* @return GeneratorOptions |
387
|
|
|
*/ |
388
|
25 |
|
public function setSrcDirname($srcDirname) |
389
|
|
|
{ |
390
|
|
|
return $this->setOptionValue(self::SRC_DIRNAME, $srcDirname); |
391
|
|
|
} |
392
|
|
|
/** |
393
|
|
|
* Get prefix option value |
394
|
770 |
|
* @return string |
395
|
|
|
*/ |
396
|
770 |
|
public function getPrefix() |
397
|
|
|
{ |
398
|
|
|
return $this->getOptionValue(self::PREFIX); |
399
|
|
|
} |
400
|
|
|
/** |
401
|
|
|
* Set current prefix option value |
402
|
|
|
* @throws \InvalidArgumentException |
403
|
|
|
* @param string $prefix |
404
|
135 |
|
* @return GeneratorOptions |
405
|
|
|
*/ |
406
|
135 |
|
public function setPrefix($prefix) |
407
|
|
|
{ |
408
|
|
|
return $this->setOptionValue(self::PREFIX, $prefix); |
409
|
|
|
} |
410
|
|
|
/** |
411
|
|
|
* Get suffix option value |
412
|
740 |
|
* @return string |
413
|
|
|
*/ |
414
|
740 |
|
public function getSuffix() |
415
|
|
|
{ |
416
|
|
|
return $this->getOptionValue(self::SUFFIX); |
417
|
|
|
} |
418
|
|
|
/** |
419
|
|
|
* Set current suffix option value |
420
|
|
|
* @throws \InvalidArgumentException |
421
|
|
|
* @param string $suffix |
422
|
65 |
|
* @return GeneratorOptions |
423
|
|
|
*/ |
424
|
65 |
|
public function setSuffix($suffix) |
425
|
|
|
{ |
426
|
|
|
return $this->setOptionValue(self::SUFFIX, $suffix); |
427
|
|
|
} |
428
|
|
|
/** |
429
|
|
|
* Get basic login option value |
430
|
780 |
|
* @return string |
431
|
|
|
*/ |
432
|
780 |
|
public function getBasicLogin() |
433
|
|
|
{ |
434
|
|
|
return $this->getOptionValue(self::BASIC_LOGIN); |
435
|
|
|
} |
436
|
|
|
/** |
437
|
|
|
* Set current basic login option value |
438
|
|
|
* @throws \InvalidArgumentException |
439
|
|
|
* @param string $basicLogin |
440
|
35 |
|
* @return GeneratorOptions |
441
|
|
|
*/ |
442
|
35 |
|
public function setBasicLogin($basicLogin) |
443
|
|
|
{ |
444
|
|
|
return $this->setOptionValue(self::BASIC_LOGIN, $basicLogin); |
445
|
|
|
} |
446
|
|
|
/** |
447
|
|
|
* Get basic password option value |
448
|
780 |
|
* @return string |
449
|
|
|
*/ |
450
|
780 |
|
public function getBasicPassword() |
451
|
|
|
{ |
452
|
|
|
return $this->getOptionValue(self::BASIC_PASSWORD); |
453
|
|
|
} |
454
|
|
|
/** |
455
|
|
|
* Set current basic password option value |
456
|
|
|
* @throws \InvalidArgumentException |
457
|
|
|
* @param string $basicPassword |
458
|
35 |
|
* @return GeneratorOptions |
459
|
|
|
*/ |
460
|
35 |
|
public function setBasicPassword($basicPassword) |
461
|
|
|
{ |
462
|
|
|
return $this->setOptionValue(self::BASIC_PASSWORD, $basicPassword); |
463
|
|
|
} |
464
|
|
|
/** |
465
|
|
|
* Get basic proxy host option value |
466
|
780 |
|
* @return string |
467
|
|
|
*/ |
468
|
780 |
|
public function getProxyHost() |
469
|
|
|
{ |
470
|
|
|
return $this->getOptionValue(self::PROXY_HOST); |
471
|
|
|
} |
472
|
|
|
/** |
473
|
|
|
* Set current proxy host option value |
474
|
|
|
* @throws \InvalidArgumentException |
475
|
|
|
* @param string $proxyHost |
476
|
35 |
|
* @return GeneratorOptions |
477
|
|
|
*/ |
478
|
35 |
|
public function setProxyHost($proxyHost) |
479
|
|
|
{ |
480
|
|
|
return $this->setOptionValue(self::PROXY_HOST, $proxyHost); |
481
|
|
|
} |
482
|
|
|
/** |
483
|
|
|
* Get basic proxy port option value |
484
|
780 |
|
* @return string |
485
|
|
|
*/ |
486
|
780 |
|
public function getProxyPort() |
487
|
|
|
{ |
488
|
|
|
return $this->getOptionValue(self::PROXY_PORT); |
489
|
|
|
} |
490
|
|
|
/** |
491
|
|
|
* Set current proxy port option value |
492
|
|
|
* @throws \InvalidArgumentException |
493
|
|
|
* @param string $proxyPort |
494
|
35 |
|
* @return GeneratorOptions |
495
|
|
|
*/ |
496
|
35 |
|
public function setProxyPort($proxyPort) |
497
|
|
|
{ |
498
|
|
|
return $this->setOptionValue(self::PROXY_PORT, $proxyPort); |
499
|
|
|
} |
500
|
|
|
/** |
501
|
|
|
* Get basic proxy login option value |
502
|
780 |
|
* @return string |
503
|
|
|
*/ |
504
|
780 |
|
public function getProxyLogin() |
505
|
|
|
{ |
506
|
|
|
return $this->getOptionValue(self::PROXY_LOGIN); |
507
|
|
|
} |
508
|
|
|
/** |
509
|
|
|
* Set current proxy login option value |
510
|
|
|
* @throws \InvalidArgumentException |
511
|
|
|
* @param string $proxyLogin |
512
|
35 |
|
* @return GeneratorOptions |
513
|
|
|
*/ |
514
|
35 |
|
public function setProxyLogin($proxyLogin) |
515
|
|
|
{ |
516
|
|
|
return $this->setOptionValue(self::PROXY_LOGIN, $proxyLogin); |
517
|
|
|
} |
518
|
|
|
/** |
519
|
|
|
* Get basic proxy password option value |
520
|
780 |
|
* @return string |
521
|
|
|
*/ |
522
|
780 |
|
public function getProxyPassword() |
523
|
|
|
{ |
524
|
|
|
return $this->getOptionValue(self::PROXY_PASSWORD); |
525
|
|
|
} |
526
|
|
|
/** |
527
|
|
|
* Set current proxy password option value |
528
|
|
|
* @throws \InvalidArgumentException |
529
|
|
|
* @param string $proxyPassword |
530
|
35 |
|
* @return GeneratorOptions |
531
|
|
|
*/ |
532
|
35 |
|
public function setProxyPassword($proxyPassword) |
533
|
|
|
{ |
534
|
|
|
return $this->setOptionValue(self::PROXY_PASSWORD, $proxyPassword); |
535
|
|
|
} |
536
|
|
|
/** |
537
|
|
|
* Get basic soap options option value |
538
|
770 |
|
* @return array |
539
|
|
|
*/ |
540
|
770 |
|
public function getSoapOptions() |
541
|
|
|
{ |
542
|
|
|
return $this->getOptionValue(self::SOAP_OPTIONS); |
543
|
|
|
} |
544
|
|
|
/** |
545
|
|
|
* Set current soap options option value |
546
|
|
|
* @throws \InvalidArgumentException |
547
|
|
|
* @param array $soapOptions |
548
|
40 |
|
* @return GeneratorOptions |
549
|
|
|
*/ |
550
|
40 |
|
public function setSoapOptions(array $soapOptions) |
551
|
|
|
{ |
552
|
|
|
return $this->setOptionValue(self::SOAP_OPTIONS, $soapOptions); |
553
|
|
|
} |
554
|
|
|
/** |
555
|
|
|
* Get composer name option value |
556
|
75 |
|
* @return string |
557
|
|
|
*/ |
558
|
75 |
|
public function getComposerName() |
559
|
|
|
{ |
560
|
|
|
return $this->getOptionValue(self::COMPOSER_NAME); |
561
|
|
|
} |
562
|
|
|
/** |
563
|
|
|
* Set current composer name option value |
564
|
|
|
* @throws \InvalidArgumentException |
565
|
|
|
* @param string $composerName |
566
|
105 |
|
* @return GeneratorOptions |
567
|
|
|
*/ |
568
|
105 |
|
public function setComposerName($composerName) |
569
|
|
|
{ |
570
|
|
|
return $this->setOptionValue(self::COMPOSER_NAME, $composerName); |
571
|
|
|
} |
572
|
|
|
/** |
573
|
|
|
* Get composer settings option value |
574
|
60 |
|
* @return array |
575
|
|
|
*/ |
576
|
60 |
|
public function getComposerSettings() |
577
|
|
|
{ |
578
|
|
|
return $this->getOptionValue(self::COMPOSER_SETTINGS); |
579
|
|
|
} |
580
|
|
|
/** |
581
|
|
|
* Set current composer settings option value |
582
|
|
|
* @throws \InvalidArgumentException |
583
|
|
|
* @param array $composerSettings |
584
|
90 |
|
* @return GeneratorOptions |
585
|
|
|
*/ |
586
|
|
|
public function setComposerSettings(array $composerSettings = []) |
587
|
|
|
{ |
588
|
|
|
/** |
589
|
90 |
|
* If array is type array("config.value:true","require:libray/src",) |
590
|
90 |
|
*/ |
591
|
35 |
|
$settings = []; |
592
|
35 |
|
foreach ($composerSettings as $index => $value) { |
593
|
35 |
|
if (is_numeric($index) && strpos($value, ':') > 0) { |
594
|
35 |
|
$path = implode('', array_slice(explode(':', $value), 0, 1)); |
595
|
21 |
|
$val = implode(':', array_slice(explode(':', $value), 1)); |
596
|
17 |
|
self::dotNotationToArray($path, $val, $settings); |
597
|
|
|
} else { |
598
|
54 |
|
$settings[$index] = $value; |
599
|
90 |
|
} |
600
|
|
|
} |
601
|
|
|
return $this->setOptionValue(self::COMPOSER_SETTINGS, $settings); |
602
|
|
|
} |
603
|
|
|
/** |
604
|
|
|
* turns my.key.path to array('my' => array('key' => array('path' => $value))) |
605
|
|
|
* @param string $string |
606
|
|
|
* @param mixed $value |
607
|
35 |
|
* @param array $array |
608
|
|
|
*/ |
609
|
35 |
|
protected static function dotNotationToArray($string, $value, array &$array) |
610
|
35 |
|
{ |
611
|
35 |
|
$keys = explode('.', $string); |
612
|
21 |
|
foreach ($keys as $key) { |
613
|
35 |
|
$array = &$array[$key]; |
614
|
35 |
|
} |
615
|
|
|
$array = ($value === 'true' || $value === 'false') ? $value === 'true' : $value; |
616
|
|
|
} |
617
|
|
|
/** |
618
|
|
|
* Get structs folder option value |
619
|
375 |
|
* @return string |
620
|
|
|
*/ |
621
|
375 |
|
public function getStructsFolder() |
622
|
|
|
{ |
623
|
|
|
return $this->getOptionValue(self::STRUCTS_FOLDER); |
624
|
|
|
} |
625
|
|
|
/** |
626
|
|
|
* Set current structs folder option value |
627
|
|
|
* @throws \InvalidArgumentException |
628
|
|
|
* @param string $structsFolder |
629
|
35 |
|
* @return GeneratorOptions |
630
|
|
|
*/ |
631
|
35 |
|
public function setStructsFolder($structsFolder) |
632
|
|
|
{ |
633
|
|
|
return $this->setOptionValue(self::STRUCTS_FOLDER, $structsFolder); |
634
|
|
|
} |
635
|
|
|
/** |
636
|
|
|
* Get arrays folder option value |
637
|
80 |
|
* @return string |
638
|
|
|
*/ |
639
|
80 |
|
public function getArraysFolder() |
640
|
|
|
{ |
641
|
|
|
return $this->getOptionValue(self::ARRAYS_FOLDER); |
642
|
|
|
} |
643
|
|
|
/** |
644
|
|
|
* Set current arrays folder option value |
645
|
|
|
* @throws \InvalidArgumentException |
646
|
|
|
* @param string $arraysFolder |
647
|
35 |
|
* @return GeneratorOptions |
648
|
|
|
*/ |
649
|
35 |
|
public function setArraysFolder($arraysFolder) |
650
|
|
|
{ |
651
|
|
|
return $this->setOptionValue(self::ARRAYS_FOLDER, $arraysFolder); |
652
|
|
|
} |
653
|
|
|
/** |
654
|
|
|
* Get enums folder option value |
655
|
150 |
|
* @return string |
656
|
|
|
*/ |
657
|
150 |
|
public function getEnumsFolder() |
658
|
|
|
{ |
659
|
|
|
return $this->getOptionValue(self::ENUMS_FOLDER); |
660
|
|
|
} |
661
|
|
|
/** |
662
|
|
|
* Set current enums folder option value |
663
|
|
|
* @throws \InvalidArgumentException |
664
|
|
|
* @param string $enumsFolder |
665
|
35 |
|
* @return GeneratorOptions |
666
|
|
|
*/ |
667
|
35 |
|
public function setEnumsFolder($enumsFolder) |
668
|
|
|
{ |
669
|
|
|
return $this->setOptionValue(self::ENUMS_FOLDER, $enumsFolder); |
670
|
|
|
} |
671
|
|
|
/** |
672
|
|
|
* Get services folder option value |
673
|
735 |
|
* @return string |
674
|
|
|
*/ |
675
|
735 |
|
public function getServicesFolder() |
676
|
|
|
{ |
677
|
|
|
return $this->getOptionValue(self::SERVICES_FOLDER); |
678
|
|
|
} |
679
|
|
|
/** |
680
|
|
|
* Set current services folder option value |
681
|
|
|
* @throws \InvalidArgumentException |
682
|
|
|
* @param string $servicesFolder |
683
|
35 |
|
* @return GeneratorOptions |
684
|
|
|
*/ |
685
|
35 |
|
public function setServicesFolder($servicesFolder) |
686
|
|
|
{ |
687
|
|
|
return $this->setOptionValue(self::SERVICES_FOLDER, $servicesFolder); |
688
|
|
|
} |
689
|
|
|
/** |
690
|
45 |
|
* Get schemas save option value |
691
|
|
|
* @return bool |
692
|
45 |
|
*/ |
693
|
45 |
|
public function getSchemasSave() |
694
|
45 |
|
{ |
695
|
27 |
|
return $this->getOptionValue(self::SCHEMAS_SAVE); |
696
|
45 |
|
} |
697
|
|
|
/** |
698
|
10 |
|
* Set schemas save option value |
699
|
|
|
* @throws \InvalidArgumentException |
700
|
10 |
|
* |
701
|
|
|
* @param bool $saveSchemas |
702
|
|
|
* |
703
|
|
|
* @return GeneratorOptions |
704
|
|
|
*/ |
705
|
|
|
public function setSchemasSave($saveSchemas) |
706
|
|
|
{ |
707
|
|
|
return $this->setOptionValue(self::SCHEMAS_SAVE, $saveSchemas); |
708
|
|
|
} |
709
|
|
|
/** |
710
|
|
|
* Get schemas folder option value |
711
|
|
|
* @return bool |
712
|
|
|
*/ |
713
|
|
|
public function getSchemasFolder() |
714
|
|
|
{ |
715
|
|
|
return $this->getOptionValue(self::SCHEMAS_FOLDER); |
716
|
|
|
} |
717
|
|
|
/** |
718
|
|
|
* Set schemas folder option value |
719
|
|
|
* @throws \InvalidArgumentException |
720
|
|
|
* |
721
|
|
|
* @param string $schemasFolder |
722
|
|
|
* |
723
|
|
|
* @return GeneratorOptions |
724
|
|
|
*/ |
725
|
|
|
public function setSchemasFolder($schemasFolder) |
726
|
|
|
{ |
727
|
|
|
return $this->setOptionValue(self::SCHEMAS_FOLDER, $schemasFolder); |
728
|
|
|
} |
729
|
|
|
/** |
730
|
|
|
* @return string[] |
731
|
|
|
*/ |
732
|
|
|
public function toArray() |
733
|
|
|
{ |
734
|
|
|
$options = []; |
735
|
|
|
foreach (array_keys($this->options) as $name) { |
736
|
|
|
$options[$name] = $this->getOptionValue($name); |
737
|
|
|
} |
738
|
|
|
return $options; |
739
|
|
|
} |
740
|
|
|
public function jsonSerialize() |
741
|
|
|
{ |
742
|
|
|
return $this->toArray(); |
743
|
|
|
} |
744
|
|
|
} |
745
|
|
|
|