SQLTransformationsPlugin.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the SQL transformations plugins
  5. *
  6. * @package PhpMyAdmin-Transformations
  7. * @subpackage SQL
  8. */
  9. declare(strict_types=1);
  10. namespace PhpMyAdmin\Plugins\Transformations\Abs;
  11. use PhpMyAdmin\Plugins\TransformationsPlugin;
  12. use PhpMyAdmin\Util;
  13. use stdClass;
  14. /**
  15. * Provides common methods for all of the SQL transformations plugins.
  16. *
  17. * @package PhpMyAdmin
  18. */
  19. abstract class SQLTransformationsPlugin extends TransformationsPlugin
  20. {
  21. /**
  22. * Gets the transformation description of the specific plugin
  23. *
  24. * @return string
  25. */
  26. public static function getInfo()
  27. {
  28. return __(
  29. 'Formats text as SQL query with syntax highlighting.'
  30. );
  31. }
  32. /**
  33. * Does the actual work of each specific transformations plugin.
  34. *
  35. * @param string $buffer text to be transformed
  36. * @param array $options transformation options
  37. * @param stdClass|null $meta meta information
  38. *
  39. * @return string
  40. */
  41. public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
  42. {
  43. return Util::formatSql($buffer);
  44. }
  45. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  46. /**
  47. * Gets the transformation name of the specific plugin
  48. *
  49. * @return string
  50. */
  51. public static function getName()
  52. {
  53. return "SQL";
  54. }
  55. }