private function populateDetail(\stdClass $locationDetail)
    {
        // The data from the API is returned under the `results` key
        if (!property_exists($locationDetail, 'results')) {
            $this->isValid = false;

            return false;
        }

        $this->latitude  = $locationDetail->results[0]->geometry->location->lat;
        $this->longitude = $locationDetail->results[0]->geometry->location->lng;

        foreach ($locationDetail->results[0]->address_components as $component) {
            if (in_array('street_number', $component->types)) {
                $this->streetNumber = $component->long_name;
            } elseif (in_array('locality', $component->types)) {
                $this->locality = $component->long_name;
                $this->shortLocality = $component->short_name;
            } elseif (in_array('postal_town', $component->types)) {
                $this->town = $component->long_name;
                $this->shortTown = $component->short_name;
            } elseif (in_array('administrative_area_level_2', $component->types)) {
                $this->country = $component->long_name;
                $this->shortCountry = $component->short_name;
            } elseif (in_array('country', $component->types)) {
                $this->country = $component->long_name;
                $this->shortCountry = $component->short_name;
            } elseif (in_array('administrative_area_level_1', $component->types)) {
                $this->district = $component->long_name;
                $this->shortDistrict = $component->short_name;
            } elseif (in_array('postal_code', $component->types)) {
                $this->postcode = $component->long_name;
            } elseif (in_array('route', $component->types)) {
                $this->streetAddress = $component->long_name;
                $this->shortStreetAddress = $component->short_name;
            } elseif (in_array('political', $component->types)) {
                $this->neighborhood = $component->long_name;
                $this->shortNeighborhood = $component->short_name;
            }
        }

        return true;
    }
private function populateDetail(\stdClass $locationDetail)
    {
        // The data from the API is returned under the `results` key
        if (!property_exists($locationDetail, 'results')) {
            $this->isValid = false;

            return false;
        }

        $this->latitude  = $locationDetail->results[0]->geometry->location->lat;
        $this->longitude = $locationDetail->results[0]->geometry->location->lng;

        foreach ($locationDetail->results[0]->address_components as $component) {
            if (in_array('street_number', $component->types)) {
                $this->streetNumber = $component->long_name;
            } elseif (in_array('locality', $component->types)) {
                $this->locality = $component->long_name;
                $this->shortLocality = $component->short_name;
            } elseif (in_array('postal_town', $component->types)) {
                $this->town = $component->long_name;
                $this->shortTown = $component->short_name;
            } elseif (in_array('administrative_area_level_2', $component->types)) {
                $this->country = $component->long_name;
                $this->shortCountry = $component->short_name;
            } elseif (in_array('country', $component->types)) {
                $this->country = $component->long_name;
                $this->shortCountry = $component->short_name;
            } elseif (in_array('administrative_area_level_1', $component->types)) {
                $this->district = $component->long_name;
                $this->shortDistrict = $component->short_name;
            } elseif (in_array('postal_code', $component->types)) {
                $this->postcode = $component->long_name;
            } elseif (in_array('route', $component->types)) {
                $this->streetAddress = $component->long_name;
                $this->shortStreetAddress = $component->short_name;
            } elseif (in_array('political', $component->types)) {
                $this->neighborhood = $component->long_name;
                $this->shortNeighborhood = $component->short_name;
            }
        }

        return true;
    }
private function populateDetail ( \ stdClass $ locationDetail ) { // The data from the API is returned under the `results` key if ( ! property_exists ( $ locationDetail , 'results' ) ) { $ this -> isValid = false ; return false ; } $ this -> latitude = $ locationDetail -> results [ 0 ] -> geometry -> location -> lat ; $ this -> longitude = $ locationDetail -> results [ 0 ] -> geometry -> location -> lng ; foreach ( $ locationDetail -> results [ 0 ] -> address_components as $ component ) { if ( in_array ( 'street_number' , $ component -> types ) ) { $ this -> streetNumber = $ component -> long_name ; } elseif ( in_array ( 'locality' , $ component -> types ) ) { $ this -> locality = $ component -> long_name ; $ this -> shortLocality = $ component -> short_name ; } elseif ( in_array ( 'postal_town' , $ component -> types ) ) { $ this -> town = $ component -> long_name ; $ this -> shortTown = $ component -> short_name ; } elseif ( in_array ( 'administrative_area_level_2' , $ component -> types ) ) { $ this -> country = $ component -> long_name ; $ this -> shortCountry = $ component -> short_name ; } elseif ( in_array ( 'country' , $ component -> types ) ) { $ this -> country = $ component -> long_name ; $ this -> shortCountry = $ component -> short_name ; } elseif ( in_array ( 'administrative_area_level_1' , $ component -> types ) ) { $ this -> district = $ component -> long_name ; $ this -> shortDistrict = $ component -> short_name ; } elseif ( in_array ( 'postal_code' , $ component -> types ) ) { $ this -> postcode = $ component -> long_name ; } elseif ( in_array ( 'route' , $ component -> types ) ) { $ this -> streetAddress = $ component -> long_name ; $ this -> shortStreetAddress = $ component -> short_name ; } elseif ( in_array ( 'political' , $ component -> types ) ) { $ this -> neighborhood = $ component -> long_name ; $ this -> shortNeighborhood = $ component -> short_name ; } } return true ; }
Populates the object with the detail from the service

@param \stdClass $locationDetail The address detail i.e. which was retrieved from the API

@return boolean          True if successfully populated the detail and false otherwise
Populates the object with the detail from the service