public function testBuildUrl()
 {
     $street = new Street(new String("Floriańska"), new String("15"));
     $country = new Country(new String(CountryCode::PL));
     $validAddress = new Address($street, new String("Krakow"), $country);
     $builder = new GoogleMapUrlBuilder(new String(GoogleMapUrlBuilder::GOOGLE_MAP_API));
     $this->assertSame(GoogleMapUrlBuilder::GOOGLE_MAP_API . "Floriańska+15,Krakow", $builder->buildUrl($validAddress));
 }
 /**
  * @return Coordinate|null
  */
 public function getCoordinate()
 {
     $url = $this->urlBuilder->buildUrl($this->address);
     $cacheKey = $this->generateCacheIndex($url);
     if ($this->cache->contains($cacheKey)) {
         $addressJsonObject = $this->cache->fetch($cacheKey);
     } else {
         $addressString = $this->contentProvider->fetch(new String($url));
         $addressJsonObject = json_decode($addressString);
         if (is_object($addressJsonObject) && $addressJsonObject->status === "OK") {
             $this->cache->save($cacheKey, $addressJsonObject);
         }
     }
     if (is_object($addressJsonObject) && $addressJsonObject->status === "OK") {
         $coordinate = new Coordinate(new Latitude($addressJsonObject->results[0]->geometry->location->lat), new Longitude($addressJsonObject->results[0]->geometry->location->lng));
         return $coordinate;
     }
     return null;
 }