| @@ 8-39 (lines=32) @@ | ||
| 5 | use Phine\Country\CountryInterface; |
|
| 6 | use Phine\Country\SubdivisionInterface; |
|
| 7 | ||
| 8 | class LocationWithState extends Location implements LocationInterface |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var SubdivisionInterface |
|
| 12 | */ |
|
| 13 | private $state; |
|
| 14 | ||
| 15 | public function __construct(CountryInterface $country, SubdivisionInterface $state) |
|
| 16 | { |
|
| 17 | parent::__construct($country); |
|
| 18 | ||
| 19 | $this->state = $state; |
|
| 20 | } |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @return SubdivisionInterface |
|
| 24 | */ |
|
| 25 | public function getState() |
|
| 26 | { |
|
| 27 | return $this->state; |
|
| 28 | } |
|
| 29 | ||
| 30 | /* LocationInterface */ |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @return string |
|
| 34 | */ |
|
| 35 | public function getLocation() |
|
| 36 | { |
|
| 37 | return $this->state->getCode(); |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||
| @@ 8-39 (lines=32) @@ | ||
| 5 | use Phine\Country\CountryInterface; |
|
| 6 | use Phine\Country\SubdivisionInterface; |
|
| 7 | ||
| 8 | class LocationWithStateAndCity extends LocationWithState implements LocationInterface |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var string |
|
| 12 | */ |
|
| 13 | private $city; |
|
| 14 | ||
| 15 | public function __construct(CountryInterface $country, SubdivisionInterface $state, $city) |
|
| 16 | { |
|
| 17 | parent::__construct($country, $state); |
|
| 18 | ||
| 19 | $this->city = $city; |
|
| 20 | } |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @return string |
|
| 24 | */ |
|
| 25 | public function getCity() |
|
| 26 | { |
|
| 27 | return $this->city; |
|
| 28 | } |
|
| 29 | ||
| 30 | /* LocationInterface */ |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @return string |
|
| 34 | */ |
|
| 35 | public function getLocation() |
|
| 36 | { |
|
| 37 | return $this->city . ' - ' . parent::getLocation(); |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||