logger->debug('Getting IP'); $response = $this->client->get('?format=json'); if (round($response->getStatusCode() / 100, 0) != 2) { throw new Exception("Could not connect to '{$this->uri}'"); } $body = $response->getBody(); $json = json_decode($body->getContents()); if (!isset($json->ip)) { throw new Exception('Missing `ip` in JSON response'); } $this->logger->debug("Current IP: {$json->ip}"); return $json->ip; } }