Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
92.31% |
12 / 13 |
|
80.00% |
4 / 5 |
CRAP | |
0.00% |
0 / 1 |
| Ellipse | |
92.31% |
12 / 13 |
|
80.00% |
4 / 5 |
9.04 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| cx | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| cy | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| rx | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
3.07 | |||
| ry | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Svg\Shape; |
| 6 | |
| 7 | use Phpdftk\Svg\Element; |
| 8 | |
| 9 | /** |
| 10 | * SVG `<ellipse>` element per SVG 2 §10.6. `cx` / `cy` default to 0 |
| 11 | * when absent. `rx` / `ry` mirror each other when only one is given |
| 12 | * — same fallback shape as `<rect>` corner radii. |
| 13 | */ |
| 14 | final class Ellipse extends Element |
| 15 | { |
| 16 | public function __construct() |
| 17 | { |
| 18 | parent::__construct('ellipse'); |
| 19 | } |
| 20 | |
| 21 | public function cx(): float |
| 22 | { |
| 23 | return $this->parseLengthOrZero('cx'); |
| 24 | } |
| 25 | |
| 26 | public function cy(): float |
| 27 | { |
| 28 | return $this->parseLengthOrZero('cy'); |
| 29 | } |
| 30 | |
| 31 | public function rx(): ?float |
| 32 | { |
| 33 | if ($this->hasAttribute('rx')) { |
| 34 | return $this->parseLengthOrZero('rx'); |
| 35 | } |
| 36 | if ($this->hasAttribute('ry')) { |
| 37 | return $this->parseLengthOrZero('ry'); |
| 38 | } |
| 39 | return null; |
| 40 | } |
| 41 | |
| 42 | public function ry(): ?float |
| 43 | { |
| 44 | if ($this->hasAttribute('ry')) { |
| 45 | return $this->parseLengthOrZero('ry'); |
| 46 | } |
| 47 | if ($this->hasAttribute('rx')) { |
| 48 | return $this->parseLengthOrZero('rx'); |
| 49 | } |
| 50 | return null; |
| 51 | } |
| 52 | } |