Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
80.00% covered (warning)
80.00%
4 / 5
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
GradientStop
80.00% covered (warning)
80.00%
4 / 5
50.00% covered (danger)
50.00%
1 / 2
3.07
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toCss
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
2.06
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Css\Value;
6
7/**
8 * One stop in a gradient: a colour plus an optional position. When the
9 * position is null the renderer interpolates based on neighbour stops.
10 *
11 * A position may also be a {@see Calc} — e.g. `calc(2em)` — which carries
12 * font-/container-relative units the cascade resolves to an absolute
13 * {@see Length} before paint. Percentages stay as authored (resolved
14 * against the gradient line at paint time).
15 */
16final readonly class GradientStop
17{
18    public function __construct(public Color $color, public Length|Percentage|Calc|null $position) {}
19
20    public function toCss(): string
21    {
22        $out = $this->color->toCss();
23        if ($this->position !== null) {
24            $out .= ' ' . $this->position->toCss();
25        }
26        return $out;
27    }
28}