Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- interface iNamed {}
- class Person implements iNamed {}
- class Dog implements iNamed {}
- $create_name = function (string $first_name, string $second_name) {
- $this->first_name = $first_name;
- $this->second_name = $second_name;
- return $this;
- };
- $create_person = $create_name->bindTo(new Person);
- $create_dog = $create_name->bindTo(new Dog);
- $harry = $create_dog('harry', 'smith');
- $max = $create_person('max', 'power');
- $full_name = function (iNamed $nameable) {
- return $nameable->first_name . ' ' . $nameable->second_name;
- };
- var_dump($full_name($max));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement