Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class animal_factory {
- public static function get_animal_obj() {
- switch (trim($_GET['animal'])) {
- case 'monkey':
- require_once self::$sub_plugin_classes_path . 'monkey.php';
- return new monkey();
- case 'sheep':
- require_once self::$sub_plugin_classes_path . 'sheep.php';
- return new sheep();
- case 'bird':
- require_once self::$sub_plugin_classes_path . 'bird.php';
- return new bird();
- default:
- throw new Exception('Unsupported animal class');
- }
- }
- }
- class animal_factory {
- public static function get_animal_obj() {
- $animal = (trim($_GET['animal']));
- require_once self::$sub_plugin_classes_path . $animal . '.php';
- return new $animal();
- }
- }
Add Comment
Please, Sign In to add comment