Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| AngleUnit | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
5 | |
100.00% |
1 / 1 |
| toDegrees | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
5 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | enum AngleUnit: string |
| 8 | { |
| 9 | case Deg = 'deg'; |
| 10 | case Rad = 'rad'; |
| 11 | case Grad = 'grad'; |
| 12 | case Turn = 'turn'; |
| 13 | |
| 14 | /** Convert this value-in-this-unit to degrees. */ |
| 15 | public function toDegrees(float $value): float |
| 16 | { |
| 17 | return match ($this) { |
| 18 | self::Deg => $value, |
| 19 | self::Rad => $value * 180 / M_PI, |
| 20 | self::Grad => $value * 0.9, |
| 21 | self::Turn => $value * 360, |
| 22 | }; |
| 23 | } |
| 24 | } |