TransformationsPlugin.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the transformations plugins
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. namespace PhpMyAdmin\Plugins;
  9. /**
  10. * Provides a common interface that will have to
  11. * be implemented by all of the transformations plugins.
  12. *
  13. * @package PhpMyAdmin
  14. */
  15. abstract class TransformationsPlugin implements TransformationsInterface
  16. {
  17. /**
  18. * Does the actual work of each specific transformations plugin.
  19. *
  20. * @param array $options transformation options
  21. *
  22. * @return void
  23. */
  24. public function applyTransformationNoWrap(array $options = array())
  25. {
  26. ;
  27. }
  28. /**
  29. * Does the actual work of each specific transformations plugin.
  30. *
  31. * @param string $buffer text to be transformed
  32. * @param array $options transformation options
  33. * @param string $meta meta information
  34. *
  35. * @return string the transformed text
  36. */
  37. abstract public function applyTransformation(
  38. $buffer,
  39. array $options = array(),
  40. $meta = ''
  41. );
  42. /**
  43. * Returns passed options or default values if they were not set
  44. *
  45. * @param string[] $options List of passed options
  46. * @param string[] $defaults List of default values
  47. *
  48. * @return string[] List of options possibly filled in by defaults.
  49. */
  50. public function getOptions(array $options, array $defaults)
  51. {
  52. $result = array();
  53. foreach ($defaults as $key => $value) {
  54. if (isset($options[$key]) && $options[$key] !== '') {
  55. $result[$key] = $options[$key];
  56. } else {
  57. $result[$key] = $value;
  58. }
  59. }
  60. return $result;
  61. }
  62. }