| 1 | <?php |
||
| 13 | trait HasRoundedValue |
||
| 14 | { |
||
| 15 | /* ----------------------------------------------------------------- |
||
| 16 | | Properties |
||
| 17 | | ----------------------------------------------------------------- |
||
| 18 | */ |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Rounding precision. |
||
| 22 | * |
||
| 23 | * @var int |
||
| 24 | */ |
||
| 25 | public $roundingPrecision = 0; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Rounding mode. |
||
| 29 | * |
||
| 30 | * @var int |
||
| 31 | */ |
||
| 32 | public $roundingMode = PHP_ROUND_HALF_UP; |
||
| 33 | |||
| 34 | /* ----------------------------------------------------------------- |
||
| 35 | | Getters & Setters |
||
| 36 | | ----------------------------------------------------------------- |
||
| 37 | */ |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Set the precision level used when rounding the value. |
||
| 41 | * |
||
| 42 | * @param int $precision |
||
| 43 | * @param int $mode |
||
| 44 | * |
||
| 45 | * @return $this |
||
| 46 | */ |
||
| 47 | 2 | public function precision($precision = 0, $mode = PHP_ROUND_HALF_UP) |
|
| 54 | |||
| 55 | /* ----------------------------------------------------------------- |
||
| 56 | | Main Methods |
||
| 57 | | ----------------------------------------------------------------- |
||
| 58 | */ |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Round the value. |
||
| 62 | * |
||
| 63 | * @param int|float $value |
||
| 64 | * |
||
| 65 | * @return float |
||
| 66 | */ |
||
| 67 | 28 | public function roundValue($value) |
|
| 71 | } |
||
| 72 |