Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
22 / 22 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| GeneratorSoapClient | |
100.00% |
22 / 22 |
|
100.00% |
6 / 6 |
8 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| initSoapClient | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
| getSoapClientOptions | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
| setSoapClient | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getSoapClient | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getSoapClientStreamContextOptions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace WsdlToPhp\PackageGenerator\Generator; |
| 6 | |
| 7 | use WsdlToPhp\PackageBase\SoapClientInterface; |
| 8 | |
| 9 | class GeneratorSoapClient extends AbstractGeneratorAware |
| 10 | { |
| 11 | protected SoapClient $soapClient; |
| 12 | |
| 13 | public function __construct(Generator $generator) |
| 14 | { |
| 15 | parent::__construct($generator); |
| 16 | $this->initSoapClient(); |
| 17 | } |
| 18 | |
| 19 | public function initSoapClient(): self |
| 20 | { |
| 21 | try { |
| 22 | $soapClient = new SoapClient($this->getSoapClientOptions(\SOAP_1_1)); |
| 23 | } catch (\SoapFault $fault) { |
| 24 | try { |
| 25 | $soapClient = new SoapClient($this->getSoapClientOptions(\SOAP_1_2)); |
| 26 | } catch (\SoapFault $fault) { |
| 27 | throw new \InvalidArgumentException(sprintf('Unable to load WSDL at "%s"!', $this->getGenerator()->getOptionOrigin()), __LINE__, $fault); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | return $this->setSoapClient($soapClient); |
| 32 | } |
| 33 | |
| 34 | public function getSoapClientOptions(int $soapVersion): array |
| 35 | { |
| 36 | return array_merge([ |
| 37 | SoapClientInterface::WSDL_SOAP_VERSION => $soapVersion, |
| 38 | SoapClientInterface::WSDL_URL => $this->getGenerator()->getOptionOrigin(), |
| 39 | SoapClientInterface::WSDL_LOGIN => $this->getGenerator()->getOptionBasicLogin(), |
| 40 | SoapClientInterface::WSDL_PROXY_HOST => $this->getGenerator()->getOptionProxyHost(), |
| 41 | SoapClientInterface::WSDL_PROXY_PORT => $this->getGenerator()->getOptionProxyPort(), |
| 42 | SoapClientInterface::WSDL_PASSWORD => $this->getGenerator()->getOptionBasicPassword(), |
| 43 | SoapClientInterface::WSDL_PROXY_LOGIN => $this->getGenerator()->getOptionProxyLogin(), |
| 44 | SoapClientInterface::WSDL_PROXY_PASSWORD => $this->getGenerator()->getOptionProxyPassword(), |
| 45 | ], $this->getGenerator()->getOptionSoapOptions()); |
| 46 | } |
| 47 | |
| 48 | public function setSoapClient(SoapClient $soapClient): self |
| 49 | { |
| 50 | $this->soapClient = $soapClient; |
| 51 | |
| 52 | return $this; |
| 53 | } |
| 54 | |
| 55 | public function getSoapClient(): SoapClient |
| 56 | { |
| 57 | return $this->soapClient; |
| 58 | } |
| 59 | |
| 60 | public function getSoapClientStreamContextOptions(): array |
| 61 | { |
| 62 | return $this->getSoapClient()->getStreamContextOptions(); |
| 63 | } |
| 64 | } |