You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MathInterface.php 1.8 KiB

4 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /*
  3. * This file is part of Hashids.
  4. *
  5. * (c) Ivan Akimov <ivan@barreleye.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Hashids\Math;
  11. /**
  12. * Interface for different math extensions.
  13. *
  14. * @author Vincent Klaiber <hello@doubledip.se>
  15. * @author Jakub Kramarz <lenwe@lenwe.net>
  16. * @author Johnson Page <jwpage@gmail.com>
  17. */
  18. interface MathInterface
  19. {
  20. /**
  21. * Add two arbitrary-length integers.
  22. *
  23. * @param string $a
  24. * @param string $b
  25. *
  26. * @return string
  27. */
  28. public function add($a, $b);
  29. /**
  30. * Multiply two arbitrary-length integers.
  31. *
  32. * @param string $a
  33. * @param string $b
  34. *
  35. * @return string
  36. */
  37. public function multiply($a, $b);
  38. /**
  39. * Divide two arbitrary-length integers.
  40. *
  41. * @param string $a
  42. * @param string $b
  43. *
  44. * @return string
  45. */
  46. public function divide($a, $b);
  47. /**
  48. * Compute arbitrary-length integer modulo.
  49. *
  50. * @param string $n
  51. * @param string $d
  52. *
  53. * @return string
  54. */
  55. public function mod($n, $d);
  56. /**
  57. * Compares two arbitrary-length integers.
  58. *
  59. * @param string $a
  60. * @param string $b
  61. *
  62. * @return bool
  63. */
  64. public function greaterThan($a, $b);
  65. /**
  66. * Converts arbitrary-length integer to PHP integer.
  67. *
  68. * @param string $a
  69. *
  70. * @return int
  71. */
  72. public function intval($a);
  73. /**
  74. * Converts arbitrary-length integer to PHP string.
  75. *
  76. * @param string $a
  77. *
  78. * @return string
  79. */
  80. public function strval($a);
  81. /**
  82. * Converts PHP integer to arbitrary-length integer.
  83. *
  84. * @param int $a
  85. *
  86. * @return string
  87. */
  88. public function get($a);
  89. }