Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
20.00% |
1 / 5 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ImageSet | |
20.00% |
1 / 5 |
|
50.00% |
1 / 2 |
4.05 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | /** |
| 8 | * `image-set(<image> [<resolution>]? [type(<mime>)]? [, ...])` |
| 9 | * per CSS Images 4 ยง6. Lets authors offer multiple resolutions |
| 10 | * (1x, 2x, ...) or formats (PNG, AVIF, WebP, ...) of the same |
| 11 | * image; the renderer selects whichever entry best matches the |
| 12 | * output target. |
| 13 | * |
| 14 | * Parser-level storage only. The selection algorithm runs once |
| 15 | * the resource loader knows the target DPR and the format |
| 16 | * negotiation policy. |
| 17 | */ |
| 18 | final readonly class ImageSet extends Value |
| 19 | { |
| 20 | /** |
| 21 | * @param list<ImageSetOption> $options |
| 22 | */ |
| 23 | public function __construct(public array $options) {} |
| 24 | |
| 25 | public function toCss(): string |
| 26 | { |
| 27 | return 'image-set(' . implode(', ', array_map( |
| 28 | static fn(ImageSetOption $o): string => $o->toCss(), |
| 29 | $this->options, |
| 30 | )) . ')'; |
| 31 | } |
| 32 | } |