@@ -92,6 +92,9 @@ |
||
| 92 | 92 | return self::BASE_URI; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | + /** |
|
| 96 | + * @return string |
|
| 97 | + */ |
|
| 95 | 98 | private function getClient(){ |
| 96 | 99 | if ($this->client === null){ |
| 97 | 100 | $settings = array(); |
@@ -6,102 +6,102 @@ |
||
| 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 | - if ($this->client === null){ |
|
| 97 | - $settings = array(); |
|
| 98 | - $settings['base_uri'] = $this->getBaseUri(); |
|
| 99 | - $settings['timeout'] = $this->getTimeout(); |
|
| 95 | + private function getClient(){ |
|
| 96 | + if ($this->client === null){ |
|
| 97 | + $settings = array(); |
|
| 98 | + $settings['base_uri'] = $this->getBaseUri(); |
|
| 99 | + $settings['timeout'] = $this->getTimeout(); |
|
| 100 | 100 | |
| 101 | - $this->client = new Client($settings); |
|
| 102 | - } |
|
| 101 | + $this->client = new Client($settings); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - return $this->client; |
|
| 105 | - } |
|
| 104 | + return $this->client; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | } |