LongToIPv4TransformationsPlugin.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Abstract class for the long to IPv4 transformations plugins
  4. */
  5. declare(strict_types=1);
  6. namespace PhpMyAdmin\Plugins\Transformations\Abs;
  7. use PhpMyAdmin\Plugins\TransformationsPlugin;
  8. use PhpMyAdmin\Utils\FormatConverter;
  9. use stdClass;
  10. use function htmlspecialchars;
  11. /**
  12. * Provides common methods for all of the long to IPv4 transformations plugins.
  13. */
  14. abstract class LongToIPv4TransformationsPlugin 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 __(
  24. 'Converts an (IPv4) Internet network address stored as a BIGINT'
  25. . ' into a string in Internet standard dotted format.'
  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 stdClass|null $meta meta information
  34. *
  35. * @return string
  36. */
  37. public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
  38. {
  39. return htmlspecialchars(FormatConverter::longToIp($buffer));
  40. }
  41. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  42. /**
  43. * Gets the transformation name of the specific plugin
  44. *
  45. * @return string
  46. */
  47. public static function getName()
  48. {
  49. return 'Long To IPv4';
  50. }
  51. }