NumberConverterInterface.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * This file is part of the ramsey/uuid library
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. *
  8. * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
  9. * @license http://opensource.org/licenses/MIT MIT
  10. * @link https://benramsey.com/projects/ramsey-uuid/ Documentation
  11. * @link https://packagist.org/packages/ramsey/uuid Packagist
  12. * @link https://github.com/ramsey/uuid GitHub
  13. */
  14. namespace Ramsey\Uuid\Converter;
  15. /**
  16. * NumberConverterInterface converts UUIDs from hexadecimal characters into
  17. * representations of integers and vice versa
  18. */
  19. interface NumberConverterInterface
  20. {
  21. /**
  22. * Converts a hexadecimal number into an integer representation of the number
  23. *
  24. * The integer representation returned may be an object or a string
  25. * representation of the integer, depending on the implementation.
  26. *
  27. * @param string $hex The hexadecimal string representation to convert
  28. * @return mixed
  29. * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
  30. */
  31. public function fromHex($hex);
  32. /**
  33. * Converts an integer representation into a hexadecimal string representation
  34. * of the number
  35. *
  36. * @param mixed $integer An integer representation to convert; this may be
  37. * a true integer, a string integer, or a object representation that
  38. * this converter can understand
  39. * @return string Hexadecimal string
  40. * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
  41. */
  42. public function toHex($integer);
  43. }