|
2 | 2 |
|
3 | 3 | namespace CodeDredd\Soap\Driver\ExtSoap; |
4 | 4 |
|
5 | | -use Phpro\SoapClient\Soap\Driver\ExtSoap\ExtSoapDriver as PhproExtSoapDriver; |
6 | 5 | use Phpro\SoapClient\Soap\Driver\ExtSoap\ExtSoapOptions; |
| 6 | +use Phpro\SoapClient\Soap\Driver\ExtSoap\Generator\DummyMethodArgumentsGenerator; |
| 7 | +use Phpro\SoapClient\Soap\Engine\DecoderInterface; |
| 8 | +use Phpro\SoapClient\Soap\Engine\DriverInterface; |
| 9 | +use Phpro\SoapClient\Soap\Engine\EncoderInterface; |
| 10 | +use Phpro\SoapClient\Soap\Engine\Metadata\MetadataFactory; |
| 11 | +use Phpro\SoapClient\Soap\Engine\Metadata\MetadataInterface; |
| 12 | +use Phpro\SoapClient\Soap\HttpBinding\SoapRequest; |
| 13 | +use Phpro\SoapClient\Soap\HttpBinding\SoapResponse; |
7 | 14 |
|
8 | | -class ExtSoapDriver extends PhproExtSoapDriver |
| 15 | +class ExtSoapDriver implements DriverInterface |
9 | 16 | { |
10 | | - public static function createFromOptions(ExtSoapOptions $options): PhproExtSoapDriver |
| 17 | + /** |
| 18 | + * @var AbusedClient |
| 19 | + */ |
| 20 | + private $client; |
| 21 | + |
| 22 | + /** |
| 23 | + * @var EncoderInterface |
| 24 | + */ |
| 25 | + private $encoder; |
| 26 | + |
| 27 | + /** |
| 28 | + * @var DecoderInterface |
| 29 | + */ |
| 30 | + private $decoder; |
| 31 | + |
| 32 | + /** |
| 33 | + * @var MetadataInterface |
| 34 | + */ |
| 35 | + private $metadata; |
| 36 | + |
| 37 | + public function __construct( |
| 38 | + AbusedClient $client, |
| 39 | + EncoderInterface $encoder, |
| 40 | + DecoderInterface $decoder, |
| 41 | + MetadataInterface $metadata |
| 42 | + ) { |
| 43 | + $this->client = $client; |
| 44 | + $this->encoder = $encoder; |
| 45 | + $this->decoder = $decoder; |
| 46 | + $this->metadata = $metadata; |
| 47 | + } |
| 48 | + |
| 49 | + public static function createFromOptions(ExtSoapOptions $options): self |
11 | 50 | { |
12 | 51 | $client = AbusedClient::createFromOptions($options); |
13 | 52 |
|
14 | | - return self::createFromClient($client); |
| 53 | + return self::createFromClient( |
| 54 | + $client, |
| 55 | + MetadataFactory::manipulated(new ExtSoapMetadata($client), $options->getMetadataOptions()) |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | + public static function createFromClient(AbusedClient $client, MetadataInterface $metadata = null): self |
| 60 | + { |
| 61 | + $metadata = $metadata ?? MetadataFactory::lazy(new ExtSoapMetadata($client)); |
| 62 | + |
| 63 | + return new self( |
| 64 | + $client, |
| 65 | + new ExtSoapEncoder($client), |
| 66 | + new ExtSoapDecoder($client, new DummyMethodArgumentsGenerator($metadata)), |
| 67 | + $metadata |
| 68 | + ); |
| 69 | + } |
| 70 | + |
| 71 | + public function decode(string $method, SoapResponse $response) |
| 72 | + { |
| 73 | + return $this->decoder->decode($method, $response); |
| 74 | + } |
| 75 | + |
| 76 | + public function encode(string $method, array $arguments): SoapRequest |
| 77 | + { |
| 78 | + return $this->encoder->encode($method, $arguments); |
| 79 | + } |
| 80 | + |
| 81 | + public function getMetadata(): MetadataInterface |
| 82 | + { |
| 83 | + return $this->metadata; |
| 84 | + } |
| 85 | + |
| 86 | + public function getClient(): AbusedClient |
| 87 | + { |
| 88 | + return $this->client; |
15 | 89 | } |
16 | 90 | } |
0 commit comments