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