dataslang /
dataslang-php
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | use GuzzleHttp\Client; |
||
| 4 | |||
| 5 | class DataslangApi { |
||
|
0 ignored issues
–
show
|
|||
| 6 | |||
| 7 | const BASE_URI = 'http://api.dataslang.com'; |
||
| 8 | |||
| 9 | private $client = null; |
||
| 10 | private $settings = array(); |
||
| 11 | private $timeout = 2.0; |
||
| 12 | |||
| 13 | public function __construct(){ |
||
| 14 | $this->initSettings(); |
||
| 15 | $this->client = new Client($this->settings); |
||
| 16 | } |
||
| 17 | |||
| 18 | public function validate($xml, $xsd){ |
||
| 19 | $result = null; |
||
| 20 | |||
| 21 | try { |
||
| 22 | |||
| 23 | |||
| 24 | // $response = $this->client->request('POST', '/validate', [ |
||
| 25 | // 'form_params' => [ |
||
| 26 | // 'field_name' => 'abc', |
||
| 27 | // 'other_field' => '123', |
||
| 28 | // 'nested_field' => [ |
||
| 29 | // 'nested' => 'hello' |
||
| 30 | // ] |
||
| 31 | // ] |
||
| 32 | // ]); |
||
| 33 | |||
| 34 | $response = $this->client->request('POST', '/validate', [ |
||
| 35 | 'form_params' => [ |
||
| 36 | 'parametro' => 'prova' |
||
| 37 | ] |
||
| 38 | ]); |
||
| 39 | |||
| 40 | $result = $res->getBody(); |
||
| 41 | |||
| 42 | } catch (\Exception $e) { |
||
| 43 | |||
| 44 | } |
||
| 45 | |||
| 46 | return $result; |
||
| 47 | } |
||
| 48 | |||
| 49 | private function initSettings(){ |
||
| 50 | $this->settings['base_uri'] = $this->getBaseUri(); |
||
| 51 | $this->settings['timeout'] = $this->getTimeout(); |
||
| 52 | } |
||
| 53 | |||
| 54 | public function setTimeout($timeout){ |
||
| 55 | $this->timeout = $timeout; |
||
| 56 | } |
||
| 57 | |||
| 58 | public function getTimeout(){ |
||
| 59 | return $this->timeout; |
||
| 60 | } |
||
| 61 | |||
| 62 | public function getBaseUri(){ |
||
| 63 | return self::BASE_URI; |
||
| 64 | } |
||
| 65 | |||
| 66 | } |
||
| 67 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.