Complex classes like SoapSettings 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 SoapSettings, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 21 | class SoapSettings  | 
            ||
| 22 | { | 
            ||
| 23 | const DEFAULT_CONNECTION_TIMEOUT = 5;  | 
            ||
| 24 | const USER_AGENT = 'WebservicesNlSoapClient/PHP/2.0';  | 
            ||
| 25 | |||
| 26 | /**  | 
            ||
| 27 | * An authentication may be supplied in the authentication option.  | 
            ||
| 28 | * The authentication method may be either SOAP_AUTHENTICATION_BASIC (default) or SOAP_AUTHENTICATION_DIGEST.  | 
            ||
| 29 | *  | 
            ||
| 30 | * @var int  | 
            ||
| 31 | */  | 
            ||
| 32 | private $authentication = SOAP_AUTHENTICATION_BASIC;  | 
            ||
| 33 | |||
| 34 | /**  | 
            ||
| 35 | * The cache_wsdl option is one of WSDL_CACHE_NONE, WSDL_CACHE_DISK, WSDL_CACHE_MEMORY or WSDL_CACHE_BOTH.  | 
            ||
| 36 | *  | 
            ||
| 37 | * @var int  | 
            ||
| 38 | */  | 
            ||
| 39 | private $cacheWsdl = WSDL_CACHE_NONE;  | 
            ||
| 40 | |||
| 41 | /**  | 
            ||
| 42 | * Optional Class map.  | 
            ||
| 43 | *  | 
            ||
| 44 | * @var array | null  | 
            ||
| 45 | */  | 
            ||
| 46 | private $classMap;  | 
            ||
| 47 | |||
| 48 | /**  | 
            ||
| 49 | * The compression option allows to use compression of HTTP SOAP requests and responses.  | 
            ||
| 50 | *  | 
            ||
| 51 | * @var int  | 
            ||
| 52 | */  | 
            ||
| 53 | private $compression = SOAP_COMPRESSION_ACCEPT;  | 
            ||
| 54 | |||
| 55 | /**  | 
            ||
| 56 | * The connection_timeout option defines a timeout in seconds for the connection to the SOAP service.  | 
            ||
| 57 | *  | 
            ||
| 58 | * This option does not define a timeout for services with slow responses. To limit the time to wait for calls to  | 
            ||
| 59 | * finish the default_socket_timeout setting is available.  | 
            ||
| 60 | *  | 
            ||
| 61 | * @var int  | 
            ||
| 62 | */  | 
            ||
| 63 | private $connectionTimeout = self::DEFAULT_CONNECTION_TIMEOUT;  | 
            ||
| 64 | |||
| 65 | /**  | 
            ||
| 66 | * The stream_context option is a resource for context.  | 
            ||
| 67 | *  | 
            ||
| 68 | * @var resource  | 
            ||
| 69 | */  | 
            ||
| 70 | private $context;  | 
            ||
| 71 | |||
| 72 | /**  | 
            ||
| 73 | * The encoding option defines internal character encoding.  | 
            ||
| 74 | * This option does not change the encoding of SOAP requests (it is always utf-8), but converts strings into it.  | 
            ||
| 75 | *  | 
            ||
| 76 | * @var  | 
            ||
| 77 | */  | 
            ||
| 78 | private $encoding = 'UTF-8';  | 
            ||
| 79 | |||
| 80 | /**  | 
            ||
| 81 | * The exceptions option is a boolean value defining whether soap errors throw exceptions of type SoapFault.  | 
            ||
| 82 | *  | 
            ||
| 83 | * @var bool  | 
            ||
| 84 | */  | 
            ||
| 85 | private $exceptions = true;  | 
            ||
| 86 | |||
| 87 | /**  | 
            ||
| 88 | * The features option is a bitmask of SOAP_SINGLE_ELEMENT_ARRAYS, SOAP_USE_XSI_ARRAY_TYPE, SOAP_WAIT_ONE_WAY_CALLS.  | 
            ||
| 89 | *  | 
            ||
| 90 | * @var int  | 
            ||
| 91 | */  | 
            ||
| 92 | private $features = SOAP_SINGLE_ELEMENT_ARRAYS;  | 
            ||
| 93 | |||
| 94 | /**  | 
            ||
| 95 | * Optional value defining whether to send the Connection: 'Keep-Alive' or Connection: 'close'.  | 
            ||
| 96 | *  | 
            ||
| 97 | * @var bool  | 
            ||
| 98 | */  | 
            ||
| 99 | private $keepAlive = true;  | 
            ||
| 100 | |||
| 101 | /**  | 
            ||
| 102 | * login username for HTTP Authentication. (optional).  | 
            ||
| 103 | *  | 
            ||
| 104 | * @var string  | 
            ||
| 105 | */  | 
            ||
| 106 | private $login;  | 
            ||
| 107 | |||
| 108 | /**  | 
            ||
| 109 | * path to cert_key.pem.  | 
            ||
| 110 | *  | 
            ||
| 111 | * @var string  | 
            ||
| 112 | */  | 
            ||
| 113 | private $localCert;  | 
            ||
| 114 | |||
| 115 | /**  | 
            ||
| 116 | * Passphrase for localCert pem.  | 
            ||
| 117 | *  | 
            ||
| 118 | * @var string  | 
            ||
| 119 | */  | 
            ||
| 120 | private $passphrase;  | 
            ||
| 121 | |||
| 122 | /**  | 
            ||
| 123 | * @var string  | 
            ||
| 124 | */  | 
            ||
| 125 | private $password;  | 
            ||
| 126 | |||
| 127 | /**  | 
            ||
| 128 | * @var string  | 
            ||
| 129 | */  | 
            ||
| 130 | private $proxyHost;  | 
            ||
| 131 | |||
| 132 | /**  | 
            ||
| 133 | * @var string  | 
            ||
| 134 | */  | 
            ||
| 135 | private $proxyLogin;  | 
            ||
| 136 | /**  | 
            ||
| 137 | * @var string  | 
            ||
| 138 | */  | 
            ||
| 139 | private $proxyPassword;  | 
            ||
| 140 | |||
| 141 | /**  | 
            ||
| 142 | * @var string  | 
            ||
| 143 | */  | 
            ||
| 144 | private $proxyPort;  | 
            ||
| 145 | |||
| 146 | /**  | 
            ||
| 147 | * All possible SOAP SSL methods.  | 
            ||
| 148 | *  | 
            ||
| 149 | * @var array  | 
            ||
| 150 | */  | 
            ||
| 151 | public static $sslMethods =  | 
            ||
| 152 | [  | 
            ||
| 153 | SOAP_SSL_METHOD_TLS,  | 
            ||
| 154 | SOAP_SSL_METHOD_SSLv2,  | 
            ||
| 155 | SOAP_SSL_METHOD_SSLv3,  | 
            ||
| 156 | SOAP_SSL_METHOD_SSLv23,  | 
            ||
| 157 | ];  | 
            ||
| 158 | |||
| 159 | /**  | 
            ||
| 160 | * The ssl_method option is one of SOAP_SSL_METHOD_TLS, SOAP_SSL_METHOD_SSLv2, SOAP_SSL_METHOD_SSLv3 or  | 
            ||
| 161 | * SOAP_SSL_METHOD_SSLv23.  | 
            ||
| 162 | *  | 
            ||
| 163 | * (Only PHP 5.5+)  | 
            ||
| 164 | *  | 
            ||
| 165 | */  | 
            ||
| 166 | private $sslMethod = SOAP_SSL_METHOD_TLS;  | 
            ||
| 167 | |||
| 168 | /**  | 
            ||
| 169 | * @var array|null  | 
            ||
| 170 | * The typemap option is an array of type mappings.  | 
            ||
| 171 | * Type mapping is an array with keys type_name, type_ns (namespace URI),  | 
            ||
| 172 | * from_xml (callback accepting one string parameter) and to_xml  | 
            ||
| 173 | * (callback accepting one object parameter).  | 
            ||
| 174 | *  | 
            ||
| 175 |      * Example array("type_ns"   => "http://schemas.nothing.com", | 
            ||
| 176 | * "type_name" => "book",  | 
            ||
| 177 | * "from_xml" => "some_function_name" callback accepting one string parameter  | 
            ||
| 178 | * "to_xml" => "some_function_name" callback accepting one string parameter")  | 
            ||
| 179 | */  | 
            ||
| 180 | private $typeMap;  | 
            ||
| 181 | |||
| 182 | /**  | 
            ||
| 183 | * Soap Version (either SOAP_1_1 or SOAP_1_2).  | 
            ||
| 184 | *  | 
            ||
| 185 | * @var int  | 
            ||
| 186 | */  | 
            ||
| 187 | private $soapVersion = SOAP_1_1;  | 
            ||
| 188 | |||
| 189 | /**  | 
            ||
| 190 | * Must be set in non-WSDL mode.  | 
            ||
| 191 | *  | 
            ||
| 192 | * @var string  | 
            ||
| 193 | */  | 
            ||
| 194 | private $uri;  | 
            ||
| 195 | |||
| 196 | /**  | 
            ||
| 197 | * The user_agent option specifies string to use in User-Agent header.  | 
            ||
| 198 | *  | 
            ||
| 199 | * @var string  | 
            ||
| 200 | */  | 
            ||
| 201 | private $userAgent = self::USER_AGENT;  | 
            ||
| 202 | |||
| 203 | /**  | 
            ||
| 204 | * Load config object from array.  | 
            ||
| 205 | *  | 
            ||
| 206 | * @param array $options  | 
            ||
| 207 | *  | 
            ||
| 208 | * @return SoapSettings  | 
            ||
| 209 | */  | 
            ||
| 210 | 7 | public static function loadFromArray(array $options)  | 
            |
| 211 |     { | 
            ||
| 212 | 7 | $options = array_filter($options);  | 
            |
| 213 | 7 | $config = new static();  | 
            |
| 214 | 7 |         foreach ($options as $key => $value) { | 
            |
| 215 | 6 | $name = 'set' . ucfirst(strtolower($key));  | 
            |
| 216 | 6 |             if (method_exists($config, $name)) { | 
            |
| 217 | 6 |                 $config->{$name}($value); | 
            |
| 218 | 6 | }  | 
            |
| 219 | 7 | }  | 
            |
| 220 | |||
| 221 | 7 | return $config;  | 
            |
| 222 | }  | 
            ||
| 223 | |||
| 224 | /**  | 
            ||
| 225 | * Return the Authentication flag.  | 
            ||
| 226 | *  | 
            ||
| 227 | * @return int  | 
            ||
| 228 | */  | 
            ||
| 229 | 1 | public function getAuthentication()  | 
            |
| 233 | |||
| 234 | /**  | 
            ||
| 235 | * Set the authentication flag.  | 
            ||
| 236 | *  | 
            ||
| 237 | * @param int $authentication  | 
            ||
| 238 | *  | 
            ||
| 239 | * @return SoapSettings  | 
            ||
| 240 | */  | 
            ||
| 241 | 1 | public function setAuthentication($authentication)  | 
            |
| 247 | |||
| 248 | /**  | 
            ||
| 249 | * Return the Cache WSDL bit flag.  | 
            ||
| 250 | *  | 
            ||
| 251 | * @return int  | 
            ||
| 252 | */  | 
            ||
| 253 | 1 | public function getCacheWsdl()  | 
            |
| 257 | |||
| 258 | /**  | 
            ||
| 259 | * @param int $cacheWsdl  | 
            ||
| 260 | *  | 
            ||
| 261 | * @return SoapSettings  | 
            ||
| 262 | */  | 
            ||
| 263 | 1 | public function setCacheWsdl($cacheWsdl)  | 
            |
| 269 | |||
| 270 | /**  | 
            ||
| 271 | * Returns class mapping.  | 
            ||
| 272 | *  | 
            ||
| 273 | * @return array|null  | 
            ||
| 274 | */  | 
            ||
| 275 | 1 | public function getClassMap()  | 
            |
| 279 | |||
| 280 | /**  | 
            ||
| 281 | * @param array $classMap  | 
            ||
| 282 | *  | 
            ||
| 283 | * @return SoapSettings  | 
            ||
| 284 | */  | 
            ||
| 285 | 1 | public function setClassMap($classMap)  | 
            |
| 291 | |||
| 292 | /**  | 
            ||
| 293 | * Return Compression flag.  | 
            ||
| 294 | *  | 
            ||
| 295 | * @return int  | 
            ||
| 296 | */  | 
            ||
| 297 | 1 | public function getCompression()  | 
            |
| 301 | |||
| 302 | /**  | 
            ||
| 303 | * @param int $compression  | 
            ||
| 304 | *  | 
            ||
| 305 | * @return SoapSettings  | 
            ||
| 306 | */  | 
            ||
| 307 | 1 | public function setCompression($compression)  | 
            |
| 308 |     { | 
            ||
| 309 | 1 |         if (in_array($compression, [SOAP_COMPRESSION_ACCEPT, SOAP_COMPRESSION_GZIP, SOAP_COMPRESSION_DEFLATE], true)) { | 
            |
| 310 | 1 | $this->compression = $compression;  | 
            |
| 311 | 1 | }  | 
            |
| 312 | |||
| 313 | 1 | return $this;  | 
            |
| 314 | }  | 
            ||
| 315 | |||
| 316 | /**  | 
            ||
| 317 | * @return int  | 
            ||
| 318 | */  | 
            ||
| 319 | 1 | public function getConnectionTimeout()  | 
            |
| 323 | |||
| 324 | /**  | 
            ||
| 325 | * @param int $connectionTimeout  | 
            ||
| 326 | *  | 
            ||
| 327 | * @return SoapSettings  | 
            ||
| 328 | *  | 
            ||
| 329 | * @throws InputException  | 
            ||
| 330 | */  | 
            ||
| 331 | 2 | public function setConnectionTimeout($connectionTimeout)  | 
            |
| 340 | |||
| 341 | /**  | 
            ||
| 342 | * @return resource  | 
            ||
| 343 | */  | 
            ||
| 344 | 1 | public function getContext()  | 
            |
| 348 | |||
| 349 | /**  | 
            ||
| 350 | * @param resource $context  | 
            ||
| 351 | *  | 
            ||
| 352 | * @return SoapSettings  | 
            ||
| 353 | */  | 
            ||
| 354 | 1 | public function setContext($context)  | 
            |
| 360 | |||
| 361 | /**  | 
            ||
| 362 | * @return string  | 
            ||
| 363 | */  | 
            ||
| 364 | 1 | public function getEncoding()  | 
            |
| 368 | |||
| 369 | /**  | 
            ||
| 370 | * @param string $encoding  | 
            ||
| 371 | *  | 
            ||
| 372 | * @return SoapSettings  | 
            ||
| 373 | */  | 
            ||
| 374 | 1 | public function setEncoding($encoding)  | 
            |
| 380 | |||
| 381 | /**  | 
            ||
| 382 | * @return bool  | 
            ||
| 383 | */  | 
            ||
| 384 | 1 | public function hasExceptions()  | 
            |
| 388 | |||
| 389 | /**  | 
            ||
| 390 | * @param bool $exceptions  | 
            ||
| 391 | *  | 
            ||
| 392 | * @return SoapSettings  | 
            ||
| 393 | */  | 
            ||
| 394 | 1 | public function setExceptions($exceptions)  | 
            |
| 400 | |||
| 401 | /**  | 
            ||
| 402 | * @return int  | 
            ||
| 403 | */  | 
            ||
| 404 | 1 | public function getFeatures()  | 
            |
| 408 | |||
| 409 | /**  | 
            ||
| 410 | * Set SoapFeatures bit mask.  | 
            ||
| 411 | *  | 
            ||
| 412 | * @param int $features  | 
            ||
| 413 | *  | 
            ||
| 414 | * @return SoapSettings  | 
            ||
| 415 | */  | 
            ||
| 416 | 1 | public function setFeatures($features)  | 
            |
| 417 |     { | 
            ||
| 418 | 1 |         if (in_array($features, [SOAP_SINGLE_ELEMENT_ARRAYS, SOAP_USE_XSI_ARRAY_TYPE, SOAP_WAIT_ONE_WAY_CALLS], true)) { | 
            |
| 419 | 1 | $this->features |= $features;  | 
            |
| 420 | 1 | }  | 
            |
| 421 | |||
| 422 | 1 | return $this;  | 
            |
| 423 | }  | 
            ||
| 424 | |||
| 425 | /**  | 
            ||
| 426 | * @return bool  | 
            ||
| 427 | */  | 
            ||
| 428 | 1 | public function isKeepAlive()  | 
            |
| 432 | |||
| 433 | /**  | 
            ||
| 434 | * @param bool $keepAlive  | 
            ||
| 435 | *  | 
            ||
| 436 | * @return SoapSettings  | 
            ||
| 437 | */  | 
            ||
| 438 | 1 | public function setKeepAlive($keepAlive)  | 
            |
| 444 | |||
| 445 | /**  | 
            ||
| 446 | * @return string  | 
            ||
| 447 | */  | 
            ||
| 448 | 1 | public function getLogin()  | 
            |
| 452 | |||
| 453 | /**  | 
            ||
| 454 | * @return string  | 
            ||
| 455 | */  | 
            ||
| 456 | 1 | public function getLocalCert()  | 
            |
| 460 | |||
| 461 | /**  | 
            ||
| 462 | * @param string $localCert  | 
            ||
| 463 | *  | 
            ||
| 464 | * @return SoapSettings  | 
            ||
| 465 | */  | 
            ||
| 466 | 1 | public function setLocalCert($localCert)  | 
            |
| 472 | |||
| 473 | /**  | 
            ||
| 474 | * @return string  | 
            ||
| 475 | */  | 
            ||
| 476 | 1 | public function getPassphrase()  | 
            |
| 480 | |||
| 481 | /**  | 
            ||
| 482 | * @param string $login  | 
            ||
| 483 | */  | 
            ||
| 484 | 1 | public function setLogin($login)  | 
            |
| 488 | |||
| 489 | /**  | 
            ||
| 490 | * @param string $passPhrase  | 
            ||
| 491 | *  | 
            ||
| 492 | * @return SoapSettings  | 
            ||
| 493 | */  | 
            ||
| 494 | 1 | public function setPassphrase($passPhrase)  | 
            |
| 500 | |||
| 501 | /**  | 
            ||
| 502 | * @return string  | 
            ||
| 503 | */  | 
            ||
| 504 | 1 | public function getPassword()  | 
            |
| 508 | |||
| 509 | /**  | 
            ||
| 510 | * @param string $password  | 
            ||
| 511 | *  | 
            ||
| 512 | * @return SoapSettings  | 
            ||
| 513 | */  | 
            ||
| 514 | 7 | public function setPassword($password)  | 
            |
| 520 | |||
| 521 | /**  | 
            ||
| 522 | * @return string  | 
            ||
| 523 | */  | 
            ||
| 524 | 1 | public function getProxyHost()  | 
            |
| 528 | |||
| 529 | /**  | 
            ||
| 530 | * @param string $proxyHost  | 
            ||
| 531 | *  | 
            ||
| 532 | * @return SoapSettings  | 
            ||
| 533 | */  | 
            ||
| 534 | 1 | public function setProxyHost($proxyHost)  | 
            |
| 540 | |||
| 541 | /**  | 
            ||
| 542 | * @return string  | 
            ||
| 543 | */  | 
            ||
| 544 | 1 | public function getProxyLogin()  | 
            |
| 548 | |||
| 549 | /**  | 
            ||
| 550 | * @param string $proxyLogin  | 
            ||
| 551 | *  | 
            ||
| 552 | * @return SoapSettings  | 
            ||
| 553 | */  | 
            ||
| 554 | 1 | public function setProxyLogin($proxyLogin)  | 
            |
| 560 | |||
| 561 | /**  | 
            ||
| 562 | * @return string  | 
            ||
| 563 | */  | 
            ||
| 564 | 1 | public function getProxyPassword()  | 
            |
| 568 | |||
| 569 | /**  | 
            ||
| 570 | * @param string $proxyPassword  | 
            ||
| 571 | *  | 
            ||
| 572 | * @return SoapSettings  | 
            ||
| 573 | */  | 
            ||
| 574 | 1 | public function setProxyPassword($proxyPassword)  | 
            |
| 580 | |||
| 581 | /**  | 
            ||
| 582 | * @return string  | 
            ||
| 583 | */  | 
            ||
| 584 | 1 | public function getProxyPort()  | 
            |
| 588 | |||
| 589 | /**  | 
            ||
| 590 | * @param string $proxyPort  | 
            ||
| 591 | *  | 
            ||
| 592 | * @return SoapSettings  | 
            ||
| 593 | */  | 
            ||
| 594 | 1 | public function setProxyPort($proxyPort)  | 
            |
| 600 | |||
| 601 | /**  | 
            ||
| 602 | * @return int  | 
            ||
| 603 | */  | 
            ||
| 604 | 7 | public function getSoapVersion()  | 
            |
| 608 | |||
| 609 | /**  | 
            ||
| 610 | * Defaults to 1.  | 
            ||
| 611 | *  | 
            ||
| 612 | * @param int $soapVersion  | 
            ||
| 613 | */  | 
            ||
| 614 | 1 | public function setSoapVersion($soapVersion)  | 
            |
| 615 |     { | 
            ||
| 616 | 1 |         if (in_array($soapVersion, [SOAP_1_1, SOAP_1_2], false)) { | 
            |
| 617 | 1 | $this->soapVersion = $soapVersion;  | 
            |
| 618 | 1 | }  | 
            |
| 619 | 1 | }  | 
            |
| 620 | |||
| 621 | /**  | 
            ||
| 622 | * @return int  | 
            ||
| 623 | */  | 
            ||
| 624 | 1 | public function getSslMethod()  | 
            |
| 628 | |||
| 629 | /**  | 
            ||
| 630 | * php 5.4+.  | 
            ||
| 631 | *  | 
            ||
| 632 | * @param int $sslMethod  | 
            ||
| 633 | *  | 
            ||
| 634 | * @return SoapSettings  | 
            ||
| 635 | */  | 
            ||
| 636 | 1 | public function setSslMethod($sslMethod)  | 
            |
| 637 |     { | 
            ||
| 638 | 1 |         if (PHP_VERSION_ID >= 50400 && in_array($sslMethod, self::$sslMethods, true)) { | 
            |
| 639 | 1 | $this->sslMethod = $sslMethod;  | 
            |
| 640 | 1 | }  | 
            |
| 641 | |||
| 642 | 1 | return $this;  | 
            |
| 643 | }  | 
            ||
| 644 | |||
| 645 | /**  | 
            ||
| 646 | * @return array|null  | 
            ||
| 647 | */  | 
            ||
| 648 | 1 | public function getTypeMap()  | 
            |
| 652 | |||
| 653 | /**  | 
            ||
| 654 | * @param array|null $typeMap  | 
            ||
| 655 | *  | 
            ||
| 656 | * @return SoapSettings  | 
            ||
| 657 | */  | 
            ||
| 658 | 1 | public function setTypeMap($typeMap)  | 
            |
| 664 | |||
| 665 | /**  | 
            ||
| 666 | * @return string  | 
            ||
| 667 | */  | 
            ||
| 668 | 1 | public function getUri()  | 
            |
| 672 | |||
| 673 | /**  | 
            ||
| 674 | * @param string $uri  | 
            ||
| 675 | *  | 
            ||
| 676 | * @return SoapSettings  | 
            ||
| 677 | */  | 
            ||
| 678 | 1 | public function setUri($uri)  | 
            |
| 684 | |||
| 685 | /**  | 
            ||
| 686 | * @return string  | 
            ||
| 687 | */  | 
            ||
| 688 | 1 | public function getUserAgent()  | 
            |
| 692 | |||
| 693 | /**  | 
            ||
| 694 | * @param string $userAgent  | 
            ||
| 695 | *  | 
            ||
| 696 | * @return SoapSettings  | 
            ||
| 697 | */  | 
            ||
| 698 | 1 | public function setUserAgent($userAgent)  | 
            |
| 704 | |||
| 705 | /**  | 
            ||
| 706 | * @return array  | 
            ||
| 707 | */  | 
            ||
| 708 | 15 | public function toArray()  | 
            |
| 712 | }  | 
            ||
| 713 |