KamranAhmed\Geocode\Geocode::get PHP Method

get() public method

Sends request to the passed Google Geocode API URL and fetches the address details and returns them
public get ( $address ) : boolean | object
$address
return boolean | object false if no data is returned by URL and the detail otherwise
    public function get($address)
    {
        if (empty($address)) {
            throw new \Exception("Address is required in order to process");
        }
        $url = $this->getServiceUrl() . "&address=" . urlencode($address);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $serviceResults = json_decode(curl_exec($ch));
        if ($serviceResults && $serviceResults->status === 'OK') {
            $this->serviceResults = $serviceResults;
            return new Location($address, $this->serviceResults);
        }
        return new Location($address, new \stdClass());
    }