Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ContextElementPaint | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| of | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\SvgToPdf; |
| 6 | |
| 7 | use Phpdftk\Svg\Value\Paint; |
| 8 | use Phpdftk\Svg\Value\Paint\ContextPaint; |
| 9 | |
| 10 | /** |
| 11 | * SVG 2 §13.2.1 — the `fill` and `stroke` of the CONTEXT ELEMENT, which |
| 12 | * `context-fill` and `context-stroke` inside a referenced subtree |
| 13 | * resolve to. |
| 14 | * |
| 15 | * The context element is the one that pulled the subtree in: the shape |
| 16 | * whose `marker-*` property referenced a `<marker>`, or a `<use>`. It |
| 17 | * is captured once, at the point of reference, rather than looked up |
| 18 | * later — by the time the marker's children are painted the painter is |
| 19 | * deep inside the marker's own cascade and the referencing shape is no |
| 20 | * longer reachable from it. |
| 21 | * |
| 22 | * A null channel means the context element declared no paint there, |
| 23 | * which the painter treats as "nothing to paint" (§13.2.1 again: the |
| 24 | * keyword resolves to `none` when there is nothing to defer to), NOT |
| 25 | * as a fall-through to the black `fill` default. |
| 26 | */ |
| 27 | final class ContextElementPaint |
| 28 | { |
| 29 | public function __construct( |
| 30 | private readonly ?Paint $fill, |
| 31 | private readonly ?Paint $stroke, |
| 32 | ) {} |
| 33 | |
| 34 | public function of(ContextPaint $keyword): ?Paint |
| 35 | { |
| 36 | return $keyword->stroke ? $this->stroke : $this->fill; |
| 37 | } |
| 38 | } |