Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <?php
  2. interface iNamed {}
  3. class Person implements iNamed {}
  4. class Dog implements iNamed {}
  5.  
  6. $create_name = function (string $first_name, string $second_name) {
  7. $this->first_name = $first_name;
  8. $this->second_name = $second_name;
  9. return $this;
  10. };
  11.  
  12. $create_person = $create_name->bindTo(new Person);
  13. $create_dog = $create_name->bindTo(new Dog);
  14.  
  15.  
  16. $harry = $create_dog('harry', 'smith');
  17. $max = $create_person('max', 'power');
  18.  
  19.  
  20. $full_name = function (iNamed $nameable) {
  21. return $nameable->first_name . ' ' . $nameable->second_name;
  22. };
  23.  
  24. var_dump($full_name($max));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement