Conditions | 7 |
Paths | 6 |
Total Lines | 23 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public function getAdapter($serviceName, array $serviceConfig) |
||
17 | { |
||
18 | if (! isset($serviceConfig['protocol']) || ! isset($serviceConfig['endpoint'])) { |
||
19 | throw new \InvalidArgumentException( |
||
20 | sprintf("Protocol and endpoint are required for remote object '%s'", $serviceName)); |
||
21 | } |
||
22 | |||
23 | $protocol = $serviceConfig['protocol']; |
||
24 | $endpoint = $serviceConfig['endpoint']; |
||
25 | |||
26 | switch ($protocol) { |
||
27 | case 'xml-rpc': |
||
28 | return new \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc(new \Zend\XmlRpc\Client($endpoint)); |
||
29 | case 'json-rpc': |
||
30 | return new \ProxyManager\Factory\RemoteObject\Adapter\JsonRpc(new \Zend\Json\Server\Client($endpoint)); |
||
31 | case 'soap': |
||
32 | return new \ProxyManager\Factory\RemoteObject\Adapter\Soap(new \Zend\Soap\Client($endpoint)); |
||
33 | case 'rest': |
||
34 | return new RestAdapter(new \Guzzle\Http\Client($endpoint)); |
||
35 | default: |
||
36 | throw new UnknownProtocolException(sprintf("Protocol '%s' is not supported ", $protocol)); |
||
37 | } |
||
38 | } |
||
39 | } |
||
40 |