Guest User

Untitled

a guest
Nov 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. class animal_factory {
  2.  
  3. public static function get_animal_obj() {
  4.  
  5. switch (trim($_GET['animal'])) {
  6. case 'monkey':
  7. require_once self::$sub_plugin_classes_path . 'monkey.php';
  8. return new monkey();
  9. case 'sheep':
  10. require_once self::$sub_plugin_classes_path . 'sheep.php';
  11. return new sheep();
  12. case 'bird':
  13. require_once self::$sub_plugin_classes_path . 'bird.php';
  14. return new bird();
  15. default:
  16. throw new Exception('Unsupported animal class');
  17. }
  18.  
  19. }
  20. }
  21.  
  22. class animal_factory {
  23.  
  24. public static function get_animal_obj() {
  25.  
  26. $animal = (trim($_GET['animal']));
  27. require_once self::$sub_plugin_classes_path . $animal . '.php';
  28. return new $animal();
  29.  
  30.  
  31. }
  32. }
Add Comment
Please, Sign In to add comment