Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ClipPath | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
5 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| clipPathUnits | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Svg; |
| 6 | |
| 7 | /** |
| 8 | * SVG `<clipPath>` per SVG 2 §14.4 — a container whose graphical children |
| 9 | * define a clipping region applied to elements that reference it via |
| 10 | * `clip-path`. The clip region is the *geometry* of the children; their |
| 11 | * paint properties don't matter, only their shape. |
| 12 | */ |
| 13 | final class ClipPath extends Element |
| 14 | { |
| 15 | public function __construct() |
| 16 | { |
| 17 | parent::__construct('clipPath'); |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * `clipPathUnits` — coordinate system the children's path data is |
| 22 | * resolved in. Default `userSpaceOnUse` per SVG 2 §14.4.1. Unknown |
| 23 | * values fall back to the default rather than failing the element. |
| 24 | * |
| 25 | * @return 'userSpaceOnUse'|'objectBoundingBox' |
| 26 | */ |
| 27 | public function clipPathUnits(): string |
| 28 | { |
| 29 | $raw = $this->getAttribute('clipPathUnits'); |
| 30 | if ($raw === null) { |
| 31 | return 'userSpaceOnUse'; |
| 32 | } |
| 33 | $value = trim($raw); |
| 34 | return match ($value) { |
| 35 | 'userSpaceOnUse', 'objectBoundingBox' => $value, |
| 36 | default => 'userSpaceOnUse', |
| 37 | }; |
| 38 | } |
| 39 | } |