Lines
100.00%
4 / 4
Methods
100.00%
2 / 2
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 3 | ||
| __toString | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| 10 | abstract readonly class Ratio implements Stringable | |
| 11 | { | |
| 12 | public float $value; | |
| 13 | ||
| 14 | /** @throws InvalidArgumentException */ | |
| 15 | final public function __construct(float $value) | |
| 16 | { | |
| 17 | if (!is_finite($value) || $value < 0.0) { | |
| 18 | throw new InvalidArgumentException("Ratio {$value} is not a finite number of zero or more."); | |
| 19 | } | |
| 20 | ||
| 21 | $this->value = $value; | |
| 22 | } | |
| 23 | ||
| 24 | final public function __toString(): string | |
| 25 | { | |
| 26 | return (string) $this->value; | |
| 27 | } | |
| 28 | } |