Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Provider/GoogleMaps/GoogleMaps.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ private function fetchUrl($url, $locale, $limit)
/** @var GoogleAddress $address */
$address = $builder->build(GoogleAddress::class);
if (isset($result->geometry->location_type)) {
$address->setLocationType($result->geometry->location_type);
$address = $address->withLocationType($result->geometry->location_type);
}
if (isset($result->types)) {
$address->setResultType($result->types);
$address = $address->withResultType($result->types);
}
$results[] = $address;

Expand Down
14 changes: 8 additions & 6 deletions src/Provider/GoogleMaps/Model/GoogleAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ final class GoogleAddress extends Address
*
* @return GoogleAddress
*/
public function setLocationType($locationType)
public function withLocationType($locationType)
{
$this->locationType = $locationType;
$new = clone $this;
$new->locationType = $locationType;

return $this;
return $new;
}

/**
Expand All @@ -62,10 +63,11 @@ public function getResultType()
*
* @return GoogleAddress
*/
public function setResultType(array $resultType)
public function withResultType(array $resultType)
{
$this->resultType = $resultType;
$new = clone $this;
$new->resultType = $resultType;

return $this;
return $new;
}
}
14 changes: 8 additions & 6 deletions src/Provider/Yandex/Model/YandexAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ public function getPrecision()
*
* @return YandexAddress
*/
public function setPrecision($precision)
public function withPrecision($precision)
{
$this->precision = $precision;
$new = clone $this;
$new->precision = $precision;

return $this;
return $new;
}

/**
Expand All @@ -64,10 +65,11 @@ public function getName()
*
* @return YandexAddress
*/
public function setName($name)
public function withName($name)
{
$this->name = $name;
$new = clone $this;
$new->name = $name;

return $this;
return $new;
}
}
4 changes: 2 additions & 2 deletions src/Provider/Yandex/Yandex.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ function ($value, $key) use (&$flatArray) {

/** @var YandexAddress $location */
$location = $builder->build(YandexAddress::class);
$location->setPrecision(isset($flatArray['precision']) ? $flatArray['precision'] : null);
$location->setName(isset($flatArray['name']) ? $flatArray['name'] : null);
$location = $location->withPrecision(isset($flatArray['precision']) ? $flatArray['precision'] : null);
$location = $location->withName(isset($flatArray['name']) ? $flatArray['name'] : null);
$locations[] = $location;
}

Expand Down