123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561 |
- <?php
- declare(strict_types=1);
- /*
- * This file is part of the Geocoder package.
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @license MIT License
- */
- namespace Geocoder\Provider\GoogleMaps\Model;
- use Geocoder\Model\Address;
- use Geocoder\Model\AdminLevel;
- use Geocoder\Model\AdminLevelCollection;
- /**
- * @author Tobias Nyholm <tobias.nyholm@gmail.com>
- */
- final class GoogleAddress extends Address
- {
- /**
- * @var string|null
- */
- private $id;
- /**
- * @var string|null
- */
- private $locationType;
- /**
- * @var array
- */
- private $resultType = [];
- /**
- * @var string|null
- */
- private $formattedAddress;
- /**
- * @var string|null
- */
- private $streetAddress;
- /**
- * @var string|null
- */
- private $intersection;
- /**
- * @var string|null
- */
- private $postalCodeSuffix;
- /**
- * @var string|null
- */
- private $political;
- /**
- * @var string|null
- */
- private $colloquialArea;
- /**
- * @var string|null
- */
- private $ward;
- /**
- * @var string|null
- */
- private $neighborhood;
- /**
- * @var string|null
- */
- private $premise;
- /**
- * @var string|null
- */
- private $subpremise;
- /**
- * @var string|null
- */
- private $naturalFeature;
- /**
- * @var string|null
- */
- private $airport;
- /**
- * @var string|null
- */
- private $park;
- /**
- * @var string|null
- */
- private $pointOfInterest;
- /**
- * @var string|null
- */
- private $establishment;
- /**
- * @var AdminLevelCollection
- */
- private $subLocalityLevels;
- /**
- * @var bool
- */
- private $partialMatch;
- /**
- * @param string|null $id
- *
- * @return GoogleAddress
- */
- public function withId(string $id = null)
- {
- $new = clone $this;
- $new->id = $id;
- return $new;
- }
- /**
- * @see https://developers.google.com/places/place-id
- *
- * @return string|null
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @param string|null $locationType
- *
- * @return GoogleAddress
- */
- public function withLocationType(string $locationType = null)
- {
- $new = clone $this;
- $new->locationType = $locationType;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getLocationType()
- {
- return $this->locationType;
- }
- /**
- * @return array
- */
- public function getResultType(): array
- {
- return $this->resultType;
- }
- /**
- * @param array $resultType
- *
- * @return GoogleAddress
- */
- public function withResultType(array $resultType)
- {
- $new = clone $this;
- $new->resultType = $resultType;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getFormattedAddress()
- {
- return $this->formattedAddress;
- }
- /**
- * @param string|null $formattedAddress
- *
- * @return GoogleAddress
- */
- public function withFormattedAddress(string $formattedAddress = null)
- {
- $new = clone $this;
- $new->formattedAddress = $formattedAddress;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getAirport()
- {
- return $this->airport;
- }
- /**
- * @param string|null $airport
- *
- * @return GoogleAddress
- */
- public function withAirport(string $airport = null)
- {
- $new = clone $this;
- $new->airport = $airport;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getColloquialArea()
- {
- return $this->colloquialArea;
- }
- /**
- * @param string|null $colloquialArea
- *
- * @return GoogleAddress
- */
- public function withColloquialArea(string $colloquialArea = null)
- {
- $new = clone $this;
- $new->colloquialArea = $colloquialArea;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getIntersection()
- {
- return $this->intersection;
- }
- /**
- * @param string|null $intersection
- *
- * @return GoogleAddress
- */
- public function withIntersection(string $intersection = null)
- {
- $new = clone $this;
- $new->intersection = $intersection;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getPostalCodeSuffix()
- {
- return $this->postalCodeSuffix;
- }
- /**
- * @param string|null $postalCodeSuffix
- *
- * @return GoogleAddress
- */
- public function withPostalCodeSuffix(string $postalCodeSuffix = null)
- {
- $new = clone $this;
- $new->postalCodeSuffix = $postalCodeSuffix;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getNaturalFeature()
- {
- return $this->naturalFeature;
- }
- /**
- * @param string|null $naturalFeature
- *
- * @return GoogleAddress
- */
- public function withNaturalFeature(string $naturalFeature = null)
- {
- $new = clone $this;
- $new->naturalFeature = $naturalFeature;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getNeighborhood()
- {
- return $this->neighborhood;
- }
- /**
- * @param string|null $neighborhood
- *
- * @return GoogleAddress
- */
- public function withNeighborhood(string $neighborhood = null)
- {
- $new = clone $this;
- $new->neighborhood = $neighborhood;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getPark()
- {
- return $this->park;
- }
- /**
- * @param string|null $park
- *
- * @return GoogleAddress
- */
- public function withPark(string $park = null)
- {
- $new = clone $this;
- $new->park = $park;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getPointOfInterest()
- {
- return $this->pointOfInterest;
- }
- /**
- * @param string|null $pointOfInterest
- *
- * @return GoogleAddress
- */
- public function withPointOfInterest(string $pointOfInterest = null)
- {
- $new = clone $this;
- $new->pointOfInterest = $pointOfInterest;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getPolitical()
- {
- return $this->political;
- }
- /**
- * @param string|null $political
- *
- * @return GoogleAddress
- */
- public function withPolitical(string $political = null)
- {
- $new = clone $this;
- $new->political = $political;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getPremise()
- {
- return $this->premise;
- }
- /**
- * @param string $premise
- *
- * @return GoogleAddress
- */
- public function withPremise(string $premise = null)
- {
- $new = clone $this;
- $new->premise = $premise;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getStreetAddress()
- {
- return $this->streetAddress;
- }
- /**
- * @param string|null $streetAddress
- *
- * @return GoogleAddress
- */
- public function withStreetAddress(string $streetAddress = null)
- {
- $new = clone $this;
- $new->streetAddress = $streetAddress;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getSubpremise()
- {
- return $this->subpremise;
- }
- /**
- * @param string|null $subpremise
- *
- * @return GoogleAddress
- */
- public function withSubpremise(string $subpremise = null)
- {
- $new = clone $this;
- $new->subpremise = $subpremise;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getWard()
- {
- return $this->ward;
- }
- /**
- * @param string|null $ward
- *
- * @return GoogleAddress
- */
- public function withWard(string $ward = null)
- {
- $new = clone $this;
- $new->ward = $ward;
- return $new;
- }
- /**
- * @return string|null
- */
- public function getEstablishment()
- {
- return $this->establishment;
- }
- /**
- * @param string|null $establishment
- *
- * @return GoogleAddress
- */
- public function withEstablishment(string $establishment = null)
- {
- $new = clone $this;
- $new->establishment = $establishment;
- return $new;
- }
- /**
- * @return AdminLevelCollection
- */
- public function getSubLocalityLevels()
- {
- return $this->subLocalityLevels;
- }
- /**
- * @param array $subLocalityLevel
- *
- * @return $this
- */
- public function withSubLocalityLevels(array $subLocalityLevel)
- {
- $subLocalityLevels = [];
- foreach ($subLocalityLevel as $level) {
- if (empty($level['level'])) {
- continue;
- }
- $name = $level['name'] ?? $level['code'] ?? '';
- if (empty($name)) {
- continue;
- }
- $subLocalityLevels[] = new AdminLevel($level['level'], $name, $level['code'] ?? null);
- }
- $subLocalityLevels = array_unique($subLocalityLevels);
- $new = clone $this;
- $new->subLocalityLevels = new AdminLevelCollection($subLocalityLevels);
- return $new;
- }
- /**
- * @return bool
- */
- public function isPartialMatch()
- {
- return $this->partialMatch;
- }
- /**
- * @param bool $partialMatch
- *
- * @return $this
- */
- public function withPartialMatch(bool $partialMatch)
- {
- $new = clone $this;
- $new->partialMatch = $partialMatch;
- return $new;
- }
- }
|