Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
70.00% covered (warning)
70.00%
7 / 10
66.67% covered (warning)
66.67%
6 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 1
FeSpotLight
70.00% covered (warning)
70.00%
7 / 10
66.67% covered (warning)
66.67%
6 / 9
12.70
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
 x
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 y
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 z
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 pointsAtX
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 pointsAtY
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 pointsAtZ
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 specularExponent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 limitingConeAngle
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Svg\Filter;
6
7use Phpdftk\Svg\Element;
8
9/**
10 * SVG 2 Filter Effects §15.15.3 — `<feSpotLight>`. Cone-shaped
11 * source for `<feDiffuseLighting>` / `<feSpecularLighting>`.
12 *
13 *   x, y, z:                   position in filter coordinates
14 *   pointsAtX/Y/Z:             aim point
15 *   specularExponent:          tightness of the cone (default 1)
16 *   limitingConeAngle:         outer half-angle in degrees;
17 *                              null = no falloff
18 */
19final class FeSpotLight extends Element
20{
21    public function __construct()
22    {
23        parent::__construct('feSpotLight');
24    }
25
26    public function x(): float
27    {
28        return (float) ($this->getAttribute('x') ?? 0);
29    }
30
31    public function y(): float
32    {
33        return (float) ($this->getAttribute('y') ?? 0);
34    }
35
36    public function z(): float
37    {
38        return (float) ($this->getAttribute('z') ?? 0);
39    }
40
41    public function pointsAtX(): float
42    {
43        return (float) ($this->getAttribute('pointsAtX') ?? 0);
44    }
45
46    public function pointsAtY(): float
47    {
48        return (float) ($this->getAttribute('pointsAtY') ?? 0);
49    }
50
51    public function pointsAtZ(): float
52    {
53        return (float) ($this->getAttribute('pointsAtZ') ?? 0);
54    }
55
56    public function specularExponent(): float
57    {
58        return max(1.0, (float) ($this->getAttribute('specularExponent') ?? 1));
59    }
60
61    public function limitingConeAngle(): ?float
62    {
63        $v = $this->getAttribute('limitingConeAngle');
64        return $v !== null ? (float) $v : null;
65    }
66}