Guest User

Untitled

a guest
Jan 19th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. <?php
  2.  
  3. trait BindMethods
  4. {
  5. private $boundMethods = [];
  6.  
  7. public function bindMethod($methodName, $method) {
  8. $this->boundMethods[$methodName] = Closure::bind($method, $this, get_class());
  9. }
  10.  
  11. function __call($method, $args) {
  12. if (is_callable('parent::__call')) {
  13. parent::__call($method, $args);
  14. }
  15.  
  16. if(is_callable($this->boundMethods[$method]))
  17. {
  18. return call_user_func_array($this->boundMethods[$method], $args);
  19. }
  20. }
  21. }
Add Comment
Please, Sign In to add comment