Created
March 18, 2011 17:32
-
-
Save kaylarose/876496 to your computer and use it in GitHub Desktop.
KISS_Dynamic_Patterns
This file contains 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 | |
class Factory{ | |
public static function create($name){ | |
if(class_exists($name, TRUE)){ | |
return new $name; | |
}else{ | |
throw new IllegalArgumentException("$name is not an invalid or unknown type"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment