Created
May 22, 2015 21:30
-
-
Save vinicius73/2b61ed2ebbef849722a3 to your computer and use it in GitHub Desktop.
Facade.php
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 | |
/** | |
* 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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Isso seria mais performático ?
return static::getFacadeRoot()->$method(...$args);