Conditions | 3 |
Paths | 5 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
25 | public function list_emoji() { |
||
26 | |||
27 | $this->setUrl("emoji.list"); |
||
28 | |||
29 | // Send the request |
||
30 | try { |
||
31 | $client = new \GuzzleHttp\Client(); |
||
32 | $json_response = $client->request('GET', $this->getUrl(), []); |
||
33 | $response = json_decode( $json_response->getBody() ); |
||
34 | } |
||
35 | catch (RequestException $e) { |
||
36 | throw new RuntimeException('The request to the API failed: '.$e->getMessage(), $e->getCode(), $e); |
||
37 | } |
||
38 | |||
39 | if($response->{'ok'} === FALSE) { |
||
40 | throw new RuntimeException('The request to the API failed: '.$response->{'error'}."."); |
||
41 | } |
||
42 | |||
43 | return $json_response->getBody(); |
||
44 | } |
||
45 | } |
||
46 |