Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| ContextPaint | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| fill | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| stroke | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Svg\Value\Paint; |
| 6 | |
| 7 | use Phpdftk\Svg\Value\Paint; |
| 8 | |
| 9 | /** |
| 10 | * SVG 2 §13.2.1 — the `context-fill` and `context-stroke` paint |
| 11 | * keywords. |
| 12 | * |
| 13 | * Both defer to the CONTEXT ELEMENT: the element that referenced the |
| 14 | * subtree this paint appears in. For a `<marker>` that is the shape |
| 15 | * whose `marker-*` property pulled the marker in; for a `<use>` it is |
| 16 | * the `<use>` itself. The point is that one arrowhead definition can |
| 17 | * take the colour of every different line it is attached to instead of |
| 18 | * needing a copy per colour. |
| 19 | * |
| 20 | * Outside any such reference there is no context element and the paint |
| 21 | * resolves to `none` — the painter's "nothing to paint" branch, not a |
| 22 | * fall-through to the black default. |
| 23 | */ |
| 24 | final class ContextPaint extends Paint |
| 25 | { |
| 26 | private function __construct(public readonly bool $stroke) {} |
| 27 | |
| 28 | public static function fill(): self |
| 29 | { |
| 30 | return new self(stroke: false); |
| 31 | } |
| 32 | |
| 33 | public static function stroke(): self |
| 34 | { |
| 35 | return new self(stroke: true); |
| 36 | } |
| 37 | } |