Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
14.29% |
1 / 7 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| TranslateTransform | |
14.29% |
1 / 7 |
|
50.00% |
1 / 2 |
20.74 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | final readonly class TranslateTransform extends TransformFunction |
| 8 | { |
| 9 | public function __construct( |
| 10 | public Length|Percentage $x, |
| 11 | public Length|Percentage $y, |
| 12 | public ?Length $z = null, |
| 13 | ) {} |
| 14 | |
| 15 | public function toCss(): string |
| 16 | { |
| 17 | if ($this->z !== null) { |
| 18 | return sprintf('translate3d(%s, %s, %s)', $this->x->toCss(), $this->y->toCss(), $this->z->toCss()); |
| 19 | } |
| 20 | $yCss = $this->y->toCss(); |
| 21 | if ($yCss === '0' || $yCss === '0px') { |
| 22 | return sprintf('translate(%s)', $this->x->toCss()); |
| 23 | } |
| 24 | return sprintf('translate(%s, %s)', $this->x->toCss(), $yCss); |
| 25 | } |
| 26 | } |