Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
20.00% |
1 / 5 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Calc | |
20.00% |
1 / 5 |
|
50.00% |
1 / 2 |
7.61 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | /** |
| 8 | * Top-level math value — `calc(...)`, `min(...)`, `max(...)`, etc. Wraps a |
| 9 | * {@see CalcExpression} tree. The cascade evaluates this lazily; here we |
| 10 | * just round-trip the parsed structure. |
| 11 | */ |
| 12 | final readonly class Calc extends Value |
| 13 | { |
| 14 | public function __construct(public CalcExpression $expression) {} |
| 15 | |
| 16 | public function toCss(): string |
| 17 | { |
| 18 | // The outermost calc() wrapper is implicit when expression already |
| 19 | // serialises with parens; otherwise wrap. |
| 20 | $inner = $this->expression->toCss(); |
| 21 | if ($this->expression instanceof CalcFunc) { |
| 22 | return $inner; |
| 23 | } |
| 24 | return 'calc' . $inner; |
| 25 | } |
| 26 | } |