Skip to content

Instantly share code, notes, and snippets.

@lstrojny
Created December 3, 2012 14:15
Show Gist options
  • Save lstrojny/4195275 to your computer and use it in GitHub Desktop.
Save lstrojny/4195275 to your computer and use it in GitHub Desktop.
<?php
trait PrototypeContainerTrait
{
    public function __call($method, array $args)
    {
        if (is_callable($this->$method)) {
            return call_user_func_array($this->$method, $args);
        }
    }
}
class Foo
{
    use PrototypeContainerTrait;
}
$foo = new Foo();
$foo->times = function($x, $y) {
    return $x * $y;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment