| Total Complexity | 5 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | final class Decimal implements Value |
||
| 17 | { |
||
| 18 | private static $definitionSet; |
||
| 19 | |||
| 20 | private $string; |
||
| 21 | private $value; |
||
| 22 | private $scale; |
||
| 23 | private $original; |
||
| 24 | |||
| 25 | 6 | public function __construct(Integer $value, Integer $scale) |
|
| 26 | { |
||
| 27 | 6 | $this->scale = (string) new UnsignedOctet($scale); |
|
| 28 | 6 | $this->value = (string) new SignedLongInteger($value); |
|
| 29 | 6 | $this->original = $value->divideBy( |
|
| 30 | 6 | (new Integer(10))->power($scale) |
|
| 31 | ); |
||
| 32 | 6 | } |
|
| 33 | |||
| 34 | 3 | public static function fromStream(Readable $stream): Value |
|
| 35 | { |
||
| 36 | 3 | $scale = UnsignedOctet::fromStream($stream)->original(); |
|
| 37 | 3 | $value = SignedLongInteger::fromStream($stream)->original(); |
|
| 38 | |||
| 39 | 3 | return new self($value, $scale); |
|
| 40 | } |
||
| 41 | |||
| 42 | 5 | public function original(): Number |
|
| 43 | { |
||
| 44 | 5 | return $this->original; |
|
| 45 | } |
||
| 46 | |||
| 47 | 5 | public function __toString(): string |
|
| 50 | } |
||
| 51 | |||
| 52 | 1 | public static function definitionSet(): Set |
|
| 55 | } |
||
| 56 | } |
||
| 57 |