Skip to content
This repository has been archived by the owner on Feb 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1 from eugenekurasov/master
Browse files Browse the repository at this point in the history
✨ Available search place (city/zip/neighborhood) by name
  • Loading branch information
Bukashk0zzz authored Oct 24, 2017
2 parents c9e6230 + 59a8376 commit 3bb0015
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions src/SearchMapsPlace.php
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)
);
}
}

0 comments on commit 3bb0015

Please sign in to comment.