@@ -6,98 +6,98 @@ |
||
6 | 6 | |
7 | 7 | class DataslangApi { |
8 | 8 | |
9 | - const BASE_URI = 'http://api.dataslang.com'; |
|
9 | + const BASE_URI = 'http://api.dataslang.com'; |
|
10 | 10 | |
11 | - private $client = null; |
|
12 | - private $settings = array(); |
|
13 | - private $timeout = 7; |
|
11 | + private $client = null; |
|
12 | + private $settings = array(); |
|
13 | + private $timeout = 7; |
|
14 | 14 | |
15 | - public function validate($xml, $xsd){ |
|
16 | - $result = null; |
|
15 | + public function validate($xml, $xsd){ |
|
16 | + $result = null; |
|
17 | 17 | |
18 | - try { |
|
18 | + try { |
|
19 | 19 | |
20 | - $client = $this->getClient(); |
|
21 | - $response = $client->request('POST', '/xml/validate', [ |
|
22 | - 'form_params' => [ |
|
23 | - 'xml' => urlencode($xml), |
|
24 | - 'xsd' => urlencode($xsd) |
|
25 | - ] |
|
26 | - ]); |
|
20 | + $client = $this->getClient(); |
|
21 | + $response = $client->request('POST', '/xml/validate', [ |
|
22 | + 'form_params' => [ |
|
23 | + 'xml' => urlencode($xml), |
|
24 | + 'xsd' => urlencode($xsd) |
|
25 | + ] |
|
26 | + ]); |
|
27 | 27 | |
28 | - $result = $response->getBody(); |
|
28 | + $result = $response->getBody(); |
|
29 | 29 | |
30 | - } catch (\Exception $e) { |
|
30 | + } catch (\Exception $e) { |
|
31 | 31 | |
32 | - } |
|
32 | + } |
|
33 | 33 | |
34 | - return $result; |
|
35 | - } |
|
34 | + return $result; |
|
35 | + } |
|
36 | 36 | |
37 | - public function transformToXml($xml, $xsl, $dest_path){ |
|
38 | - $result = null; |
|
37 | + public function transformToXml($xml, $xsl, $dest_path){ |
|
38 | + $result = null; |
|
39 | 39 | |
40 | - try { |
|
40 | + try { |
|
41 | 41 | |
42 | - $client = $this->getClient(); |
|
43 | - $response = $client->request('POST', '/xml/transform/xml', [ |
|
44 | - 'form_params' => [ |
|
45 | - 'xml' => urlencode($xml), |
|
46 | - 'xsl' => urlencode($xsl), |
|
47 | - 'dest_path' => urlencode($dest_path) |
|
48 | - ] |
|
49 | - ]); |
|
42 | + $client = $this->getClient(); |
|
43 | + $response = $client->request('POST', '/xml/transform/xml', [ |
|
44 | + 'form_params' => [ |
|
45 | + 'xml' => urlencode($xml), |
|
46 | + 'xsl' => urlencode($xsl), |
|
47 | + 'dest_path' => urlencode($dest_path) |
|
48 | + ] |
|
49 | + ]); |
|
50 | 50 | |
51 | - $result = $response->getBody(); |
|
51 | + $result = $response->getBody(); |
|
52 | 52 | |
53 | - } catch (\Exception $e) { |
|
53 | + } catch (\Exception $e) { |
|
54 | 54 | |
55 | - } |
|
55 | + } |
|
56 | 56 | |
57 | - return $result; |
|
58 | - } |
|
57 | + return $result; |
|
58 | + } |
|
59 | 59 | |
60 | - public function transformToHtml($xml, $xsl, $dest_path){ |
|
61 | - $result = null; |
|
60 | + public function transformToHtml($xml, $xsl, $dest_path){ |
|
61 | + $result = null; |
|
62 | 62 | |
63 | - try { |
|
63 | + try { |
|
64 | 64 | |
65 | - $client = $this->getClient(); |
|
66 | - $response = $client->request('POST', '/xml/transform/html', [ |
|
67 | - 'form_params' => [ |
|
68 | - 'xml' => urlencode($xml), |
|
69 | - 'xsl' => urlencode($xsl), |
|
70 | - 'dest_path' => urlencode($dest_path) |
|
71 | - ] |
|
72 | - ]); |
|
65 | + $client = $this->getClient(); |
|
66 | + $response = $client->request('POST', '/xml/transform/html', [ |
|
67 | + 'form_params' => [ |
|
68 | + 'xml' => urlencode($xml), |
|
69 | + 'xsl' => urlencode($xsl), |
|
70 | + 'dest_path' => urlencode($dest_path) |
|
71 | + ] |
|
72 | + ]); |
|
73 | 73 | |
74 | - $result = $response->getBody(); |
|
74 | + $result = $response->getBody(); |
|
75 | 75 | |
76 | - } catch (\Exception $e) { |
|
76 | + } catch (\Exception $e) { |
|
77 | 77 | |
78 | - } |
|
78 | + } |
|
79 | 79 | |
80 | - return $result; |
|
81 | - } |
|
80 | + return $result; |
|
81 | + } |
|
82 | 82 | |
83 | - public function setTimeout($timeout){ |
|
84 | - $this->timeout = $timeout; |
|
85 | - } |
|
83 | + public function setTimeout($timeout){ |
|
84 | + $this->timeout = $timeout; |
|
85 | + } |
|
86 | 86 | |
87 | - public function getTimeout(){ |
|
88 | - return $this->timeout; |
|
89 | - } |
|
87 | + public function getTimeout(){ |
|
88 | + return $this->timeout; |
|
89 | + } |
|
90 | 90 | |
91 | - public function getBaseUri(){ |
|
92 | - return self::BASE_URI; |
|
93 | - } |
|
91 | + public function getBaseUri(){ |
|
92 | + return self::BASE_URI; |
|
93 | + } |
|
94 | 94 | |
95 | - private function getClient(){ |
|
96 | - $settings = array(); |
|
97 | - $settings['base_uri'] = $this->getBaseUri(); |
|
98 | - $settings['timeout'] = $this->getTimeout(); |
|
95 | + private function getClient(){ |
|
96 | + $settings = array(); |
|
97 | + $settings['base_uri'] = $this->getBaseUri(); |
|
98 | + $settings['timeout'] = $this->getTimeout(); |
|
99 | 99 | |
100 | - return new Client($settings); |
|
101 | - } |
|
100 | + return new Client($settings); |
|
101 | + } |
|
102 | 102 | |
103 | 103 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | private $settings = array(); |
13 | 13 | private $timeout = 7; |
14 | 14 | |
15 | - public function validate($xml, $xsd){ |
|
15 | + public function validate($xml, $xsd) { |
|
16 | 16 | $result = null; |
17 | 17 | |
18 | 18 | try { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | return $result; |
35 | 35 | } |
36 | 36 | |
37 | - public function transformToXml($xml, $xsl, $dest_path){ |
|
37 | + public function transformToXml($xml, $xsl, $dest_path) { |
|
38 | 38 | $result = null; |
39 | 39 | |
40 | 40 | try { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | return $result; |
58 | 58 | } |
59 | 59 | |
60 | - public function transformToHtml($xml, $xsl, $dest_path){ |
|
60 | + public function transformToHtml($xml, $xsl, $dest_path) { |
|
61 | 61 | $result = null; |
62 | 62 | |
63 | 63 | try { |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | return $result; |
81 | 81 | } |
82 | 82 | |
83 | - public function setTimeout($timeout){ |
|
83 | + public function setTimeout($timeout) { |
|
84 | 84 | $this->timeout = $timeout; |
85 | 85 | } |
86 | 86 | |
87 | - public function getTimeout(){ |
|
87 | + public function getTimeout() { |
|
88 | 88 | return $this->timeout; |
89 | 89 | } |
90 | 90 | |
91 | - public function getBaseUri(){ |
|
91 | + public function getBaseUri() { |
|
92 | 92 | return self::BASE_URI; |
93 | 93 | } |
94 | 94 | |
95 | - private function getClient(){ |
|
95 | + private function getClient() { |
|
96 | 96 | $settings = array(); |
97 | - $settings['base_uri'] = $this->getBaseUri(); |
|
98 | - $settings['timeout'] = $this->getTimeout(); |
|
97 | + $settings[ 'base_uri' ] = $this->getBaseUri(); |
|
98 | + $settings[ 'timeout' ] = $this->getTimeout(); |
|
99 | 99 | |
100 | 100 | return new Client($settings); |
101 | 101 | } |