Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
9.09% |
1 / 11 |
|
33.33% |
1 / 3 |
CRAP | |
0.00% |
0 / 1 |
| MatrixTransform | |
9.09% |
1 / 11 |
|
33.33% |
1 / 3 |
16.02 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| 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 | /** `matrix(a, b, c, d, e, f)` — the 2D affine matrix form. */ |
| 8 | final readonly class MatrixTransform extends TransformFunction |
| 9 | { |
| 10 | public function __construct( |
| 11 | public float $a, |
| 12 | public float $b, |
| 13 | public float $c, |
| 14 | public float $d, |
| 15 | public float $e, |
| 16 | public float $f, |
| 17 | ) {} |
| 18 | |
| 19 | public function toCss(): string |
| 20 | { |
| 21 | return sprintf( |
| 22 | 'matrix(%s, %s, %s, %s, %s, %s)', |
| 23 | self::trim($this->a), |
| 24 | self::trim($this->b), |
| 25 | self::trim($this->c), |
| 26 | self::trim($this->d), |
| 27 | self::trim($this->e), |
| 28 | self::trim($this->f), |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | private static function trim(float $v): string |
| 33 | { |
| 34 | return fmod($v, 1.0) === 0.0 ? (string) (int) $v : (string) $v; |
| 35 | } |
| 36 | } |