Skip to content

Instantly share code, notes, and snippets.

@vinicius73
Created May 22, 2015 21:30
Show Gist options
  • Save vinicius73/2b61ed2ebbef849722a3 to your computer and use it in GitHub Desktop.
Save vinicius73/2b61ed2ebbef849722a3 to your computer and use it in GitHub Desktop.
Facade.php
<?php
/**
* Handle dynamic, static calls to the object.
*/
public static function __callStatic($method, $args)
{
$instance = static::getFacadeRoot();
switch (count($args))
{
case 0:
return $instance->$method();
case 1:
return $instance->$method($args[0]);
case 2:
return $instance->$method($args[0], $args[1]);
case 3:
return $instance->$method($args[0], $args[1], $args[2]);
case 4:
return $instance->$method($args[0], $args[1], $args[2], $args[3]);
default:
return call_user_func_array(array($instance, $method), $args);
}
}
@LucasMotadev
Copy link

Isso seria mais performático ?

return static::getFacadeRoot()->$method(...$args);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment