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