Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Country {
- private $value;
- public function __construct(string $value)
- {
- $this->value = $value;
- }
- public function __toString(): string
- {
- return $this->value;
- }
- }
- class Locale {
- private $value;
- private $country;
- public function __construct(string $value, Country $country) {
- $this->value = $value;
- $this->country = (string)$country;
- }
- public function presentWith(callable $presenter): array {
- return $presenter($this->value, $this->country);
- }
- }
- $locale = new Locale('RU', new Country('RUSSIA'));
- $present = $locale->presentWith(function(string $locale, string $country) {
- return [
- 'locale' => $locale,
- 'country' => $country
- ];
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement