Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
FilterPrimitive
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
6 / 6
10
100.00% covered (success)
100.00%
1 / 1
 x
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 y
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 width
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 height
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 in
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 result
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Svg\Filter;
6
7use Phpdftk\Svg\Element;
8
9/**
10 * SVG 2 Filter Effects §6.2 — common base for the `<fe*>` filter
11 * primitives (`<feGaussianBlur>`, `<feColorMatrix>`, etc.). Each
12 * primitive sits inside a `<filter>` element and consumes one or
13 * two inputs (`in` / `in2`) producing one named output (`result`).
14 *
15 * The "primitive subregion" attributes (`x`, `y`, `width`, `height`)
16 * crop the primitive's effect rectangle inside the filter region.
17 * Defaults come from the parent `<filter>`'s `primitiveUnits` — for
18 * `userSpaceOnUse` the defaults are the filter region; for
19 * `objectBoundingBox` the defaults are 0/0/100%/100% of the
20 * referencing shape's bbox.
21 *
22 * Standard input names (used by the `in` / `in2` attributes):
23 *
24 *   SourceGraphic       — the referencing element's rendering
25 *   SourceAlpha         — the alpha channel of SourceGraphic
26 *   BackgroundImage     — what's behind the element (gated by
27 *                         `enable-background` on an ancestor)
28 *   BackgroundAlpha     — the alpha channel of BackgroundImage
29 *   FillPaint           — the element's resolved fill paint
30 *   StrokePaint         — the element's resolved stroke paint
31 *
32 *   <result-name>       — a previously-emitted result name from
33 *                         a sibling primitive
34 */
35abstract class FilterPrimitive extends Element
36{
37    public function x(): ?float
38    {
39        $v = $this->getAttribute('x');
40        return $v !== null ? (float) $v : null;
41    }
42
43    public function y(): ?float
44    {
45        $v = $this->getAttribute('y');
46        return $v !== null ? (float) $v : null;
47    }
48
49    public function width(): ?float
50    {
51        $v = $this->getAttribute('width');
52        return $v !== null ? (float) $v : null;
53    }
54
55    public function height(): ?float
56    {
57        $v = $this->getAttribute('height');
58        return $v !== null ? (float) $v : null;
59    }
60
61    /**
62     * Input source name. `null` (= attribute absent) means the
63     * primitive consumes whatever the previous sibling produced
64     * (or `SourceGraphic` if it's the first child).
65     */
66    public function in(): ?string
67    {
68        return $this->getAttribute('in');
69    }
70
71    /**
72     * Result name. `null` means the primitive doesn't expose a
73     * named result; it can still be consumed by the next sibling
74     * as the implicit input.
75     */
76    public function result(): ?string
77    {
78        return $this->getAttribute('result');
79    }
80}