Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| CrossFadeOption | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | /** |
| 8 | * One `[<percentage>? <image>]` entry inside {@see CrossFade}. |
| 9 | * The percentage is optional; the renderer distributes the |
| 10 | * remaining weight equally across unlabeled entries. |
| 11 | */ |
| 12 | final readonly class CrossFadeOption |
| 13 | { |
| 14 | public function __construct( |
| 15 | public Value $image, |
| 16 | public ?float $percent = null, |
| 17 | ) {} |
| 18 | |
| 19 | public function toCss(): string |
| 20 | { |
| 21 | if ($this->percent !== null) { |
| 22 | return rtrim(rtrim(sprintf('%.4f', $this->percent), '0'), '.') . '% ' . $this->image->toCss(); |
| 23 | } |
| 24 | return $this->image->toCss(); |
| 25 | } |
| 26 | } |