Created
December 6, 2016 12:18
-
-
Save SebDeclercq/7dac64cff82e5ea9294347757632c7d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| abstract class ModifiableAtRuntime | |
| { | |
| protected $methodes; | |
| public function ajouteMethode($nom, Closure $closure) { | |
| $this->methodes[$nom] = $closure->bindTo($this, __CLASS__); | |
| } | |
| public function __call($methode, $args) { | |
| if (is_callable($this->methodes[$methode])) { | |
| return call_user_func_array($this->methodes[$methode], $args); | |
| } | |
| } | |
| public function __invoke($nom, $closure) { | |
| $this->ajouteMethode($nom, $closure); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment