@@ -8,68 +8,68 @@ |
||
8 | 8 | |
9 | 9 | class GuzzleHttpAdapter implements HttpInterface{ |
10 | 10 | |
11 | - /** |
|
12 | - * @var Client |
|
13 | - */ |
|
14 | - protected $client; |
|
11 | + /** |
|
12 | + * @var Client |
|
13 | + */ |
|
14 | + protected $client; |
|
15 | 15 | |
16 | - public function __construct() |
|
17 | - { |
|
18 | - $this->client = new Client(); |
|
19 | - } |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + $this->client = new Client(); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * @param $uri |
|
23 | - * @param array $params |
|
24 | - * @return array |
|
25 | - */ |
|
26 | - public function get($uri, $params = []) |
|
27 | - { |
|
28 | - if(!empty($params)){ |
|
29 | - $uri .= '?'. http_build_query($params); |
|
30 | - } |
|
31 | - $response = $this |
|
32 | - ->client |
|
33 | - ->get($uri) |
|
34 | - ->send(); |
|
21 | + /** |
|
22 | + * @param $uri |
|
23 | + * @param array $params |
|
24 | + * @return array |
|
25 | + */ |
|
26 | + public function get($uri, $params = []) |
|
27 | + { |
|
28 | + if(!empty($params)){ |
|
29 | + $uri .= '?'. http_build_query($params); |
|
30 | + } |
|
31 | + $response = $this |
|
32 | + ->client |
|
33 | + ->get($uri) |
|
34 | + ->send(); |
|
35 | 35 | |
36 | - return $this->parseResponse($response); |
|
37 | - } |
|
36 | + return $this->parseResponse($response); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $uri |
|
41 | - * @param array $body |
|
42 | - * @return array |
|
43 | - */ |
|
44 | - public function post($uri, $body) |
|
45 | - { |
|
46 | - $response = $this |
|
47 | - ->client |
|
48 | - ->post($uri, [], $body) |
|
49 | - ->send(); |
|
50 | - return $this->parseResponse($response); |
|
51 | - } |
|
39 | + /** |
|
40 | + * @param string $uri |
|
41 | + * @param array $body |
|
42 | + * @return array |
|
43 | + */ |
|
44 | + public function post($uri, $body) |
|
45 | + { |
|
46 | + $response = $this |
|
47 | + ->client |
|
48 | + ->post($uri, [], $body) |
|
49 | + ->send(); |
|
50 | + return $this->parseResponse($response); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param string $url |
|
55 | - * @return $this |
|
56 | - */ |
|
57 | - public function setBaseUrl($url) |
|
58 | - { |
|
59 | - $this->client->setBaseUrl($url); |
|
53 | + /** |
|
54 | + * @param string $url |
|
55 | + * @return $this |
|
56 | + */ |
|
57 | + public function setBaseUrl($url) |
|
58 | + { |
|
59 | + $this->client->setBaseUrl($url); |
|
60 | 60 | |
61 | - return $this; |
|
62 | - } |
|
61 | + return $this; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
64 | + /** |
|
65 | 65 | * Parses XML from response and returns it as an array |
66 | 66 | * |
67 | - * @param Response $response |
|
68 | - * @return array |
|
69 | - */ |
|
70 | - protected function parseResponse(Response $response) |
|
71 | - { |
|
72 | - $xml = simplexml_load_string($response->getBody(true)); |
|
67 | + * @param Response $response |
|
68 | + * @return array |
|
69 | + */ |
|
70 | + protected function parseResponse(Response $response) |
|
71 | + { |
|
72 | + $xml = simplexml_load_string($response->getBody(true)); |
|
73 | 73 | return (array)$xml->children(); |
74 | - } |
|
74 | + } |
|
75 | 75 | } |
76 | 76 | \ No newline at end of file |
@@ -31,9 +31,9 @@ |
||
31 | 31 | */ |
32 | 32 | public function toXml() |
33 | 33 | { |
34 | - return $this->initDom() |
|
35 | - ->createParamsNodes() |
|
36 | - ->getXml(); |
|
34 | + return $this->initDom() |
|
35 | + ->createParamsNodes() |
|
36 | + ->getXml(); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -4,23 +4,23 @@ |
||
4 | 4 | |
5 | 5 | interface HttpInterface { |
6 | 6 | |
7 | - /** |
|
8 | - * @param $uri |
|
9 | - * @param array $params |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - public function get($uri, $params = []); |
|
7 | + /** |
|
8 | + * @param $uri |
|
9 | + * @param array $params |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + public function get($uri, $params = []); |
|
13 | 13 | |
14 | - /** |
|
15 | - * @param $uri |
|
16 | - * @param $body |
|
17 | - * @return array |
|
18 | - */ |
|
19 | - public function post($uri, $body); |
|
14 | + /** |
|
15 | + * @param $uri |
|
16 | + * @param $body |
|
17 | + * @return array |
|
18 | + */ |
|
19 | + public function post($uri, $body); |
|
20 | 20 | |
21 | - /** |
|
22 | - * @param string $url |
|
23 | - * @return $this |
|
24 | - */ |
|
25 | - public function setBaseUrl($url); |
|
21 | + /** |
|
22 | + * @param string $url |
|
23 | + * @return $this |
|
24 | + */ |
|
25 | + public function setBaseUrl($url); |
|
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -4,10 +4,10 @@ |
||
4 | 4 | |
5 | 5 | interface RequestInterface { |
6 | 6 | |
7 | - /** |
|
8 | - * Send the request to API |
|
9 | - * @param $uri |
|
10 | - * @param $params |
|
11 | - */ |
|
12 | - public function exec($uri, $params); |
|
7 | + /** |
|
8 | + * Send the request to API |
|
9 | + * @param $uri |
|
10 | + * @param $params |
|
11 | + */ |
|
12 | + public function exec($uri, $params); |
|
13 | 13 | } |
14 | 14 | \ No newline at end of file |