Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
88.89% covered (warning)
88.89%
8 / 9
85.71% covered (warning)
85.71%
6 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
FeComposite
88.89% covered (warning)
88.89%
8 / 9
85.71% covered (warning)
85.71%
6 / 7
8.09
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 operator
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 in2
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 k1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 k2
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 k3
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 k4
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
7/**
8 * SVG 2 Filter Effects §15.6 — `<feComposite operator in in2>`.
9 * Porter-Duff composite of two inputs.
10 *
11 *   operator: over (default) | in | out | atop | xor | lighter |
12 *             arithmetic
13 *
14 * When `operator="arithmetic"` the four k coefficients drive the
15 * per-pixel formula `result = k1·in·in2 + k2·in + k3·in2 + k4`.
16 */
17final class FeComposite extends FilterPrimitive
18{
19    public function __construct()
20    {
21        parent::__construct('feComposite');
22    }
23
24    public function operator(): string
25    {
26        $v = strtolower($this->getAttribute('operator') ?? 'over');
27        $known = ['over', 'in', 'out', 'atop', 'xor', 'lighter', 'arithmetic'];
28        return in_array($v, $known, true) ? $v : 'over';
29    }
30
31    public function in2(): ?string
32    {
33        return $this->getAttribute('in2');
34    }
35
36    public function k1(): float
37    {
38        return (float) ($this->getAttribute('k1') ?? 0);
39    }
40
41    public function k2(): float
42    {
43        return (float) ($this->getAttribute('k2') ?? 0);
44    }
45
46    public function k3(): float
47    {
48        return (float) ($this->getAttribute('k3') ?? 0);
49    }
50
51    public function k4(): float
52    {
53        return (float) ($this->getAttribute('k4') ?? 0);
54    }
55}