Calculator
4 years ago
Currencies
4 years ago
Exception
4 years ago
Exchange
4 years ago
Formatter
4 years ago
PHPUnit
4 years ago
Parser
4 years ago
Calculator.php
4 years ago
Converter.php
4 years ago
Currencies.php
4 years ago
Currency.php
4 years ago
CurrencyPair.php
4 years ago
Exception.php
4 years ago
Exchange.php
4 years ago
Money.php
4 years ago
MoneyFactory.php
4 years ago
MoneyFormatter.php
4 years ago
MoneyParser.php
4 years ago
Number.php
4 years ago
Calculator.php
128 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Money; |
| 4 | |
| 5 | /** |
| 6 | * Money calculations abstracted away from the Money value object. |
| 7 | * |
| 8 | * @author Frederik Bosch <f.bosch@genkgo.nl> |
| 9 | */ |
| 10 | interface Calculator |
| 11 | { |
| 12 | /** |
| 13 | * Returns whether the calculator is supported in |
| 14 | * the current server environment. |
| 15 | * |
| 16 | * @return bool |
| 17 | */ |
| 18 | public static function supported(); |
| 19 | |
| 20 | /** |
| 21 | * Compare a to b. |
| 22 | * |
| 23 | * @param string $a |
| 24 | * @param string $b |
| 25 | * |
| 26 | * @return int |
| 27 | */ |
| 28 | public function compare($a, $b); |
| 29 | |
| 30 | /** |
| 31 | * Add added to amount. |
| 32 | * |
| 33 | * @param string $amount |
| 34 | * @param string $addend |
| 35 | * |
| 36 | * @return string |
| 37 | */ |
| 38 | public function add($amount, $addend); |
| 39 | |
| 40 | /** |
| 41 | * Subtract subtrahend from amount. |
| 42 | * |
| 43 | * @param string $amount |
| 44 | * @param string $subtrahend |
| 45 | * |
| 46 | * @return string |
| 47 | */ |
| 48 | public function subtract($amount, $subtrahend); |
| 49 | |
| 50 | /** |
| 51 | * Multiply amount with multiplier. |
| 52 | * |
| 53 | * @param string $amount |
| 54 | * @param int|float|string $multiplier |
| 55 | * |
| 56 | * @return string |
| 57 | */ |
| 58 | public function multiply($amount, $multiplier); |
| 59 | |
| 60 | /** |
| 61 | * Divide amount with divisor. |
| 62 | * |
| 63 | * @param string $amount |
| 64 | * @param int|float|string $divisor |
| 65 | * |
| 66 | * @return string |
| 67 | */ |
| 68 | public function divide($amount, $divisor); |
| 69 | |
| 70 | /** |
| 71 | * Round number to following integer. |
| 72 | * |
| 73 | * @param string $number |
| 74 | * |
| 75 | * @return string |
| 76 | */ |
| 77 | public function ceil($number); |
| 78 | |
| 79 | /** |
| 80 | * Round number to preceding integer. |
| 81 | * |
| 82 | * @param string $number |
| 83 | * |
| 84 | * @return string |
| 85 | */ |
| 86 | public function floor($number); |
| 87 | |
| 88 | /** |
| 89 | * Returns the absolute value of the number. |
| 90 | * |
| 91 | * @param string $number |
| 92 | * |
| 93 | * @return string |
| 94 | */ |
| 95 | public function absolute($number); |
| 96 | |
| 97 | /** |
| 98 | * Round number, use rounding mode for tie-breaker. |
| 99 | * |
| 100 | * @param int|float|string $number |
| 101 | * @param int $roundingMode |
| 102 | * |
| 103 | * @return string |
| 104 | */ |
| 105 | public function round($number, $roundingMode); |
| 106 | |
| 107 | /** |
| 108 | * Share amount among ratio / total portions. |
| 109 | * |
| 110 | * @param string $amount |
| 111 | * @param int|float|string $ratio |
| 112 | * @param int|float|string $total |
| 113 | * |
| 114 | * @return string |
| 115 | */ |
| 116 | public function share($amount, $ratio, $total); |
| 117 | |
| 118 | /** |
| 119 | * Get the modulus of an amount. |
| 120 | * |
| 121 | * @param string $amount |
| 122 | * @param int|float|string $divisor |
| 123 | * |
| 124 | * @return string |
| 125 | */ |
| 126 | public function mod($amount, $divisor); |
| 127 | } |
| 128 |