GisFactory.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Contains the factory class that handles the creation of geometric objects
  4. */
  5. declare(strict_types=1);
  6. namespace PhpMyAdmin\Gis;
  7. use function strtoupper;
  8. /**
  9. * Factory class that handles the creation of geometric objects.
  10. */
  11. class GisFactory
  12. {
  13. /**
  14. * Returns the singleton instance of geometric class of the given type.
  15. *
  16. * @param string $type type of the geometric object
  17. *
  18. * @return GisGeometry|false the singleton instance of geometric class of the given type
  19. *
  20. * @access public
  21. * @static
  22. */
  23. public static function factory($type)
  24. {
  25. switch (strtoupper($type)) {
  26. case 'MULTIPOLYGON':
  27. return GisMultiPolygon::singleton();
  28. case 'POLYGON':
  29. return GisPolygon::singleton();
  30. case 'MULTIPOINT':
  31. return GisMultiPoint::singleton();
  32. case 'POINT':
  33. return GisPoint::singleton();
  34. case 'MULTILINESTRING':
  35. return GisMultiLineString::singleton();
  36. case 'LINESTRING':
  37. return GisLineString::singleton();
  38. case 'GEOMETRYCOLLECTION':
  39. return GisGeometryCollection::singleton();
  40. default:
  41. return false;
  42. }
  43. }
  44. }