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