SQLTransformationsPlugin.php 1.3 KB

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