Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- trait BindMethods
- {
- private $boundMethods = [];
- public function bindMethod($methodName, $method) {
- $this->boundMethods[$methodName] = Closure::bind($method, $this, get_class());
- }
- function __call($method, $args) {
- if (is_callable('parent::__call')) {
- parent::__call($method, $args);
- }
- if(is_callable($this->boundMethods[$method]))
- {
- return call_user_func_array($this->boundMethods[$method], $args);
- }
- }
- }
Add Comment
Please, Sign In to add comment