@@ -6,96 +6,96 @@ |
||
| 6 | 6 | |
| 7 | 7 | class DataslangApi { |
| 8 | 8 | |
| 9 | - const BASE_URI = 'http://api.dataslang'; |
|
| 9 | + const BASE_URI = 'http://api.dataslang'; |
|
| 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){ |
|
| 38 | - $result = null; |
|
| 37 | + public function transformToXml($xml){ |
|
| 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 | - ] |
|
| 47 | - ]); |
|
| 42 | + $client = $this->getClient(); |
|
| 43 | + $response = $client->request('POST', '/xml/transform/xml', [ |
|
| 44 | + 'form_params' => [ |
|
| 45 | + 'xml' => urlencode($xml) |
|
| 46 | + ] |
|
| 47 | + ]); |
|
| 48 | 48 | |
| 49 | - $result = $response->getBody(); |
|
| 49 | + $result = $response->getBody(); |
|
| 50 | 50 | |
| 51 | - } catch (\Exception $e) { |
|
| 51 | + } catch (\Exception $e) { |
|
| 52 | 52 | |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - return $result; |
|
| 56 | - } |
|
| 55 | + return $result; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function transformToHtml($xml, $xsl, $dest_path){ |
|
| 59 | - $result = null; |
|
| 58 | + public function transformToHtml($xml, $xsl, $dest_path){ |
|
| 59 | + $result = null; |
|
| 60 | 60 | |
| 61 | - try { |
|
| 61 | + try { |
|
| 62 | 62 | |
| 63 | - $client = $this->getClient(); |
|
| 64 | - $response = $client->request('POST', '/xml/transform/html', [ |
|
| 65 | - 'form_params' => [ |
|
| 66 | - 'xml' => urlencode($xml), |
|
| 67 | - 'xsl' => urlencode($xsl), |
|
| 68 | - 'dest_path' => urlencode($dest_path) |
|
| 69 | - ] |
|
| 70 | - ]); |
|
| 63 | + $client = $this->getClient(); |
|
| 64 | + $response = $client->request('POST', '/xml/transform/html', [ |
|
| 65 | + 'form_params' => [ |
|
| 66 | + 'xml' => urlencode($xml), |
|
| 67 | + 'xsl' => urlencode($xsl), |
|
| 68 | + 'dest_path' => urlencode($dest_path) |
|
| 69 | + ] |
|
| 70 | + ]); |
|
| 71 | 71 | |
| 72 | - $result = $response->getBody(); |
|
| 72 | + $result = $response->getBody(); |
|
| 73 | 73 | |
| 74 | - } catch (\Exception $e) { |
|
| 74 | + } catch (\Exception $e) { |
|
| 75 | 75 | |
| 76 | - } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - return $result; |
|
| 79 | - } |
|
| 78 | + return $result; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - public function setTimeout($timeout){ |
|
| 82 | - $this->timeout = $timeout; |
|
| 83 | - } |
|
| 81 | + public function setTimeout($timeout){ |
|
| 82 | + $this->timeout = $timeout; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - public function getTimeout(){ |
|
| 86 | - return $this->timeout; |
|
| 87 | - } |
|
| 85 | + public function getTimeout(){ |
|
| 86 | + return $this->timeout; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - public function getBaseUri(){ |
|
| 90 | - return self::BASE_URI; |
|
| 91 | - } |
|
| 89 | + public function getBaseUri(){ |
|
| 90 | + return self::BASE_URI; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - private function getClient(){ |
|
| 94 | - $settings = array(); |
|
| 95 | - $settings['base_uri'] = $this->getBaseUri(); |
|
| 96 | - $settings['timeout'] = $this->getTimeout(); |
|
| 93 | + private function getClient(){ |
|
| 94 | + $settings = array(); |
|
| 95 | + $settings['base_uri'] = $this->getBaseUri(); |
|
| 96 | + $settings['timeout'] = $this->getTimeout(); |
|
| 97 | 97 | |
| 98 | - return new Client($settings); |
|
| 99 | - } |
|
| 98 | + return new Client($settings); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | } |
@@ -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){ |
|
| 37 | + public function transformToXml($xml) { |
|
| 38 | 38 | $result = null; |
| 39 | 39 | |
| 40 | 40 | try { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | return $result; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function transformToHtml($xml, $xsl, $dest_path){ |
|
| 58 | + public function transformToHtml($xml, $xsl, $dest_path) { |
|
| 59 | 59 | $result = null; |
| 60 | 60 | |
| 61 | 61 | try { |
@@ -78,22 +78,22 @@ discard block |
||
| 78 | 78 | return $result; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function setTimeout($timeout){ |
|
| 81 | + public function setTimeout($timeout) { |
|
| 82 | 82 | $this->timeout = $timeout; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function getTimeout(){ |
|
| 85 | + public function getTimeout() { |
|
| 86 | 86 | return $this->timeout; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function getBaseUri(){ |
|
| 89 | + public function getBaseUri() { |
|
| 90 | 90 | return self::BASE_URI; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - private function getClient(){ |
|
| 93 | + private function getClient() { |
|
| 94 | 94 | $settings = array(); |
| 95 | - $settings['base_uri'] = $this->getBaseUri(); |
|
| 96 | - $settings['timeout'] = $this->getTimeout(); |
|
| 95 | + $settings[ 'base_uri' ] = $this->getBaseUri(); |
|
| 96 | + $settings[ 'timeout' ] = $this->getTimeout(); |
|
| 97 | 97 | |
| 98 | 98 | return new Client($settings); |
| 99 | 99 | } |