Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
LinearEasing
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toCss
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Css\Value;
6
7/**
8 * `linear(<linear-stop-list>)` per CSS Easing 2 §3.1. Defines a
9 * piecewise-linear easing function as a sequence of `(output,
10 * input?)` pairs. Used in `animation-timing-function`,
11 * `transition-timing-function`, and `offset-rotate` interpolations.
12 *
13 *   linear(0, 0.5 50%, 1)          three-stop linear
14 *   linear(0 0%, 1 100%)           explicit anchors
15 *   linear(0, 0.25 25% 50%, 1)     range form (CSS Easing 2 §3.2)
16 *
17 * For the range form (`<output> <input-from>% <input-to>%`), we
18 * store each instance as two LinearEasingStop entries sharing the
19 * same output — equivalent to a horizontal segment of the
20 * piecewise function.
21 */
22final readonly class LinearEasing extends Value
23{
24    /**
25     * @param list<LinearEasingStop> $stops
26     */
27    public function __construct(public array $stops) {}
28
29    public function toCss(): string
30    {
31        $parts = [];
32        foreach ($this->stops as $stop) {
33            $parts[] = $stop->toCss();
34        }
35        return 'linear(' . implode(', ', $parts) . ')';
36    }
37}