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