Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
90.00% |
9 / 10 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| LinearEasingStop | |
90.00% |
9 / 10 |
|
50.00% |
1 / 2 |
5.03 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
88.89% |
8 / 9 |
|
0.00% |
0 / 1 |
4.02 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | /** |
| 8 | * One stop in a {@see LinearEasing}. `output` is the eased value |
| 9 | * at this position. `inputPercent` is the optional input |
| 10 | * percentage anchor — null when the position should be auto- |
| 11 | * distributed between the previous and next anchors per CSS |
| 12 | * Easing 2 §3.1's interpolation rule. |
| 13 | */ |
| 14 | final readonly class LinearEasingStop |
| 15 | { |
| 16 | public function __construct( |
| 17 | public float $output, |
| 18 | public ?float $inputPercent = null, |
| 19 | ) {} |
| 20 | |
| 21 | public function toCss(): string |
| 22 | { |
| 23 | $out = fmod($this->output, 1.0) === 0.0 |
| 24 | ? (string) (int) $this->output |
| 25 | : (string) $this->output; |
| 26 | if ($this->inputPercent === null) { |
| 27 | return $out; |
| 28 | } |
| 29 | $pct = fmod($this->inputPercent, 1.0) === 0.0 |
| 30 | ? (string) (int) $this->inputPercent |
| 31 | : (string) $this->inputPercent; |
| 32 | return $out . ' ' . $pct . '%'; |
| 33 | } |
| 34 | } |