/** * Get Response from API * * @param $data * @return bool|Response * @throws \Exception */ private static function getResponse($data) { $jsonData = json_decode($data); if (!$jsonData) { throw new \Exception('ziplocate.us answered with an unknown response'); } else { $response = new Response(); $response->setLat($jsonData->lat); $response->setLng($jsonData->lng); $response->setZip($jsonData->zip); return $response; } return false; }