| Total Complexity | 7 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class FloatValue extends AbstractValue |
||
| 8 | { |
||
| 9 | private float $value; |
||
| 10 | |||
| 11 | 4 | private function __construct(float $value, bool $cache) |
|
| 12 | { |
||
| 13 | 4 | $this->value = $value; |
|
| 14 | |||
| 15 | 4 | if ($cache) { |
|
| 16 | 1 | self::cacheStore($value, $this); |
|
| 17 | } |
||
| 18 | 4 | } |
|
| 19 | |||
| 20 | /** |
||
| 21 | * Creates the value object. |
||
| 22 | * |
||
| 23 | * @param float $value The float value |
||
| 24 | * @param bool $cache Cache the value so we reuse the same object |
||
| 25 | * |
||
| 26 | * @return FloatValue The value object |
||
| 27 | */ |
||
| 28 | 6 | public static function create(float $value, bool $cache = false): self |
|
| 29 | { |
||
| 30 | 6 | $object = $cache ? parent::cacheRetrieve($value) : null; |
|
| 31 | |||
| 32 | 6 | if (null === $object) { |
|
| 33 | 4 | $object = new self($value, $cache); |
|
| 34 | } |
||
| 35 | |||
| 36 | 6 | return $object; |
|
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Exposes the stored float value. |
||
| 41 | * |
||
| 42 | * @return float The float value |
||
| 43 | */ |
||
| 44 | 4 | public function getValue(): float |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Compares if the value of a given object matches with this object. |
||
| 51 | * |
||
| 52 | * @param FloatValue $object The input object to be compared |
||
| 53 | * |
||
| 54 | * @return bool TRUE if the value matches; FALSE otherwise |
||
| 55 | */ |
||
| 56 | 2 | public function equals(FloatValue $object): bool |
|
| 61 |