This repository has been archived by the owner on Feb 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from eugenekurasov/master
✨ Available search place (city/zip/neighborhood) by name
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Rentberry\MapsUtils; | ||
|
||
use Rentberry\MapsUtils\Objects\Place; | ||
|
||
/** | ||
* Contains logic for search address on mapsPlace | ||
*/ | ||
class SearchMapsPlace | ||
{ | ||
/** | ||
* @var MapsPlace | ||
*/ | ||
private $mapsPlace; | ||
|
||
/** | ||
* SearchMapsPlace constructor. | ||
* | ||
* @param MapsPlace $mapsPlace | ||
*/ | ||
public function __construct(MapsPlace $mapsPlace) | ||
{ | ||
$this->mapsPlace = $mapsPlace; | ||
} | ||
|
||
/** | ||
* @param string $city | ||
* @param string $zip | ||
* @param null|string $state | ||
* | ||
* @return Place|null | ||
*/ | ||
public function searchZipPlace(string $city, string $zip, ?string $state = null): ?Place | ||
{ | ||
return $this->mapsPlace->getPlaceByAddress( | ||
\sprintf('%s-%s-%s', $city, $state, $zip) | ||
); | ||
} | ||
|
||
/** | ||
* @param string $city | ||
* @param null|string $state | ||
* | ||
* @return Place|null | ||
*/ | ||
public function searchCityPlace(string $city, ?string $state = null): ?Place | ||
{ | ||
return $this->mapsPlace->getPlaceByAddress( | ||
\sprintf('%s-%s', $city, $state) | ||
); | ||
} | ||
|
||
/** | ||
* @param string $neighborhood | ||
* @param string $city | ||
* @param null|string $state | ||
* | ||
* @return Place|null | ||
*/ | ||
public function searchNeighborhoodPlace(string $neighborhood, string $city, ?string $state = null): ?Place | ||
{ | ||
return $this->mapsPlace->getPlaceByAddress( | ||
\sprintf('%s-%s-%s', $neighborhood, $city, $state) | ||
); | ||
} | ||
} |