Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
33.33% |
1 / 3 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Length | |
33.33% |
1 / 3 |
|
50.00% |
1 / 2 |
5.67 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | final readonly class Length extends Value |
| 8 | { |
| 9 | public function __construct(public float $value, public LengthUnit $unit) {} |
| 10 | |
| 11 | public function toCss(): string |
| 12 | { |
| 13 | $val = fmod($this->value, 1.0) === 0.0 ? (string) (int) $this->value : (string) $this->value; |
| 14 | return $val . $this->unit->value; |
| 15 | } |
| 16 | } |