Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
50.00% |
2 / 4 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| Angle | |
50.00% |
2 / 4 |
|
66.67% |
2 / 3 |
6.00 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toDegrees | |
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 Angle extends Value |
| 8 | { |
| 9 | public function __construct(public float $value, public AngleUnit $unit) {} |
| 10 | |
| 11 | public function toDegrees(): float |
| 12 | { |
| 13 | return $this->unit->toDegrees($this->value); |
| 14 | } |
| 15 | |
| 16 | public function toCss(): string |
| 17 | { |
| 18 | $val = fmod($this->value, 1.0) === 0.0 ? (string) (int) $this->value : (string) $this->value; |
| 19 | return $val . $this->unit->value; |
| 20 | } |
| 21 | } |