Last active
October 1, 2015 05:58
-
-
Save ringmaster/1933104 to your computer and use it in GitHub Desktop.
Fluid PHP Create
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 | |
// Explained (somewhat) at http://redalt.com/fluid-php-baseobject-class | |
trait FluentCreate | |
{ | |
public static function create() | |
{ | |
$class = get_called_class(); | |
$args = func_get_args(); | |
$r_class = new \ReflectionClass($class); | |
return $r_class->newInstanceArgs($args); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment