Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
9.09% |
1 / 11 |
|
33.33% |
1 / 3 |
CRAP | |
0.00% |
0 / 1 |
| RotateTransform | |
9.09% |
1 / 11 |
|
33.33% |
1 / 3 |
43.81 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
20 | |||
| trim | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | final readonly class RotateTransform extends TransformFunction |
| 8 | { |
| 9 | public function __construct( |
| 10 | public float $angleDeg, |
| 11 | public float $ax = 0.0, |
| 12 | public float $ay = 0.0, |
| 13 | public float $az = 1.0, |
| 14 | ) {} |
| 15 | |
| 16 | public function toCss(): string |
| 17 | { |
| 18 | if ($this->ax !== 0.0 || $this->ay !== 0.0 || $this->az !== 1.0) { |
| 19 | return sprintf( |
| 20 | 'rotate3d(%s, %s, %s, %sdeg)', |
| 21 | self::trim($this->ax), |
| 22 | self::trim($this->ay), |
| 23 | self::trim($this->az), |
| 24 | self::trim($this->angleDeg), |
| 25 | ); |
| 26 | } |
| 27 | return sprintf('rotate(%sdeg)', self::trim($this->angleDeg)); |
| 28 | } |
| 29 | |
| 30 | private static function trim(float $v): string |
| 31 | { |
| 32 | return fmod($v, 1.0) === 0.0 ? (string) (int) $v : (string) $v; |
| 33 | } |
| 34 | } |