Calculator.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * League.Uri (https://uri.thephpleague.com)
  4. *
  5. * (c) Ignace Nyamagana Butera <nyamsprod@gmail.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. declare(strict_types=1);
  11. namespace League\Uri\IPv4;
  12. interface Calculator
  13. {
  14. /**
  15. * Add numbers.
  16. *
  17. * @param mixed $value1 a number that will be added to $value2
  18. * @param mixed $value2 a number that will be added to $value1
  19. *
  20. * @return mixed the addition result
  21. */
  22. public function add(mixed $value1, mixed $value2);
  23. /**
  24. * Subtract one number from another.
  25. *
  26. * @param mixed $value1 a number that will be subtracted of $value2
  27. * @param mixed $value2 a number that will be subtracted to $value1
  28. *
  29. * @return mixed the subtraction result
  30. */
  31. public function sub(mixed $value1, mixed $value2);
  32. /**
  33. * Multiply numbers.
  34. *
  35. * @param mixed $value1 a number that will be multiplied by $value2
  36. * @param mixed $value2 a number that will be multiplied by $value1
  37. *
  38. * @return mixed the multiplication result
  39. */
  40. public function multiply(mixed $value1, mixed $value2);
  41. /**
  42. * Divide numbers.
  43. *
  44. * @param mixed $value The number being divided.
  45. * @param mixed $base The number that $value is being divided by.
  46. *
  47. * @return mixed the result of the division
  48. */
  49. public function div(mixed $value, mixed $base);
  50. /**
  51. * Raise an number to the power of exponent.
  52. *
  53. * @param mixed $value scalar, the base to use
  54. *
  55. * @return mixed the value raised to the power of exp.
  56. */
  57. public function pow(mixed $value, int $exponent);
  58. /**
  59. * Returns the int point remainder (modulo) of the division of the arguments.
  60. *
  61. * @param mixed $value The dividend
  62. * @param mixed $base The divisor
  63. *
  64. * @return mixed the remainder
  65. */
  66. public function mod(mixed $value, mixed $base);
  67. /**
  68. * Number comparison.
  69. *
  70. * @param mixed $value1 the first value
  71. * @param mixed $value2 the second value
  72. *
  73. * @return int Returns < 0 if value1 is less than value2; > 0 if value1 is greater than value2, and 0 if they are equal.
  74. */
  75. public function compare(mixed $value1, mixed $value2): int;
  76. /**
  77. * Get the decimal integer value of a variable.
  78. *
  79. * @param mixed $value The scalar value being converted to an integer
  80. *
  81. * @return mixed the integer value
  82. */
  83. public function baseConvert(mixed $value, int $base);
  84. }