Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
76.92% |
20 / 26 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| InterpolationMethodCss | |
76.92% |
20 / 26 |
|
0.00% |
0 / 2 |
27.95 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| serialise | |
80.00% |
20 / 25 |
|
0.00% |
0 / 1 |
24.53 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | /** |
| 8 | * Internal helper — serialise an `in <space> [<hue-interp> hue]` |
| 9 | * clause for the CSS Images 4 §3.1.2 gradient interpolation |
| 10 | * method. Centralises the colorspace→string + hue-interp→string |
| 11 | * mapping so all three gradient types render the clause the |
| 12 | * same way. |
| 13 | */ |
| 14 | final class InterpolationMethodCss |
| 15 | { |
| 16 | private function __construct() {} |
| 17 | |
| 18 | public static function serialise(?ColorSpace $space, ?HueInterpolation $hue): string |
| 19 | { |
| 20 | if ($space === null) { |
| 21 | return ''; |
| 22 | } |
| 23 | $name = match ($space) { |
| 24 | ColorSpace::sRGB => 'srgb', |
| 25 | ColorSpace::sRGBLinear => 'srgb-linear', |
| 26 | ColorSpace::DisplayP3 => 'display-p3', |
| 27 | ColorSpace::DisplayP3Linear => 'display-p3-linear', |
| 28 | ColorSpace::A98RGB => 'a98-rgb', |
| 29 | ColorSpace::A98RGBLinear => 'a98-rgb-linear', |
| 30 | ColorSpace::ProPhotoRGB => 'prophoto-rgb', |
| 31 | ColorSpace::ProPhotoRGBLinear => 'prophoto-rgb-linear', |
| 32 | ColorSpace::Rec2020 => 'rec2020', |
| 33 | ColorSpace::Rec2020Linear => 'rec2020-linear', |
| 34 | ColorSpace::Lab => 'lab', |
| 35 | ColorSpace::Lch => 'lch', |
| 36 | ColorSpace::OKLab => 'oklab', |
| 37 | ColorSpace::OKLCH => 'oklch', |
| 38 | ColorSpace::XYZ => 'xyz', |
| 39 | ColorSpace::XYZD50 => 'xyz-d50', |
| 40 | ColorSpace::XYZD65 => 'xyz-d65', |
| 41 | ColorSpace::HWB => 'hwb', |
| 42 | }; |
| 43 | $out = ' in ' . $name; |
| 44 | if ($hue !== null) { |
| 45 | $out .= ' ' . $hue->value . ' hue'; |
| 46 | } |
| 47 | return $out; |
| 48 | } |
| 49 | } |