Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
12 | public static function get() |
||
13 | { |
||
14 | |||
15 | try { |
||
16 | $response = Requests::get(Settings::$endpoint, array('User-Agent' => Settings::buildUserAgent())); |
||
17 | } catch (Requests_Exception $e) { |
||
18 | throw new ConnectionError("The request failed because it wasn't able to reach the ipify service. |
||
19 | This is most likely due to a networking error of some sort."); |
||
20 | } |
||
21 | |||
22 | if ($response->status_code !== 200) { |
||
23 | throw new ServiceError('Received an invalid status code from ipify:' . (string) $response->status_code . |
||
24 | '. The service might be experiencing issues.'); |
||
25 | } |
||
26 | |||
27 | return $response->body; |
||
28 | |||
29 | } |
||
30 | |||
32 |