Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
25.00% |
1 / 4 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Number | |
25.00% |
1 / 4 |
|
50.00% |
1 / 2 |
6.80 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | final readonly class Number extends Value |
| 8 | { |
| 9 | public function __construct(public float $value) {} |
| 10 | |
| 11 | public function toCss(): string |
| 12 | { |
| 13 | // Preserve integer-like display when fractional part is zero. |
| 14 | if (fmod($this->value, 1.0) === 0.0) { |
| 15 | return (string) (int) $this->value; |
| 16 | } |
| 17 | return (string) $this->value; |
| 18 | } |
| 19 | } |