| 1 | <?php |
||
| 12 | final class CitySearchBuilder |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | private $query; |
||
| 18 | |||
| 19 | private function __construct() |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @return CitySearchBuilder |
||
| 28 | */ |
||
| 29 | public static function create(): self |
||
| 30 | { |
||
| 31 | return new static(); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return CitySearchBuilder |
||
| 36 | */ |
||
| 37 | public function page(int $page): self |
||
| 38 | { |
||
| 39 | $this->query['p'] = $page; |
||
| 40 | |||
| 41 | return $this; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return CitySearchBuilder |
||
| 46 | */ |
||
| 47 | public function withName(string $name): self |
||
| 48 | { |
||
| 49 | $this->query['name'] = $name; |
||
| 50 | |||
| 51 | return $this; |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @return CitySearchBuilder |
||
| 56 | */ |
||
| 57 | public function withCountry(string $country): self |
||
| 58 | { |
||
| 59 | $this->query['country'] = $country; |
||
| 60 | |||
| 61 | return $this; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return CitySearchBuilder |
||
| 66 | */ |
||
| 67 | public function withState(string $name): self |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @return CitySearchBuilder |
||
| 76 | */ |
||
| 77 | public function withStateCode(string $code): self |
||
| 83 | |||
| 84 | public function getQuery(): array |
||
| 88 | } |
||
| 89 |