Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Number
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toCss
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Css\Value;
6
7final 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}