| 1 | <?php |
||
| 7 | class Decimal implements JsonSerializable |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @const int Default number of decimals. |
||
| 11 | */ |
||
| 12 | const DEFAULT_DECIMALS = 2; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var int The stored value. |
||
| 16 | */ |
||
| 17 | public $value; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Constructor. |
||
| 21 | * |
||
| 22 | * @param int $value |
||
| 23 | */ |
||
| 24 | 2 | public function __construct($value) |
|
| 28 | |||
| 29 | /** |
||
| 30 | * Creates an instance using the specified format. |
||
| 31 | * |
||
| 32 | * @param DateTime $value |
||
| 33 | * @param int $decimals |
||
| 34 | * |
||
| 35 | * @return self |
||
| 36 | */ |
||
| 37 | 2 | public static function fromFloat( |
|
| 43 | |||
| 44 | /** |
||
| 45 | * Converts to float type. |
||
| 46 | * |
||
| 47 | * @param int $decimals |
||
| 48 | * |
||
| 49 | * @return float |
||
| 50 | */ |
||
| 51 | 1 | public function toFloat($decimals = self::DEFAULT_DECIMALS) |
|
| 55 | |||
| 56 | /** |
||
| 57 | * @inheritdoc |
||
| 58 | */ |
||
| 59 | 1 | public function jsonSerialize() |
|
| 63 | } |
||
| 64 |