Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
FeBlend
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 mode
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
2
 in2
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.4 — `<feBlend mode in in2>`. Mixes
9 * two inputs using a Porter-Duff / blend-mode pixel-pair function.
10 *
11 * `mode` matches the CSS Compositing 1 §3 blend-mode keywords:
12 *
13 *   normal | multiply | screen | overlay | darken | lighten |
14 *   color-dodge | color-burn | hard-light | soft-light |
15 *   difference | exclusion | hue | saturation | color | luminosity
16 */
17final class FeBlend extends FilterPrimitive
18{
19    public function __construct()
20    {
21        parent::__construct('feBlend');
22    }
23
24    public function mode(): string
25    {
26        $v = strtolower($this->getAttribute('mode') ?? 'normal');
27        $known = [
28            'normal', 'multiply', 'screen', 'overlay', 'darken', 'lighten',
29            'color-dodge', 'color-burn', 'hard-light', 'soft-light',
30            'difference', 'exclusion', 'hue', 'saturation', 'color', 'luminosity',
31        ];
32        return in_array($v, $known, true) ? $v : 'normal';
33    }
34
35    public function in2(): ?string
36    {
37        return $this->getAttribute('in2');
38    }
39}