Completed
Push — master ( 1f6ac0...60e18b )
by Edgar
16:30
created

Ellipse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 1
cbo 1
dl 0
loc 25
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getName() 0 4 1
A getBoundingBox() 0 9 1
1
<?php
2
namespace nstdio\svg\shape;
3
4
use nstdio\svg\ElementInterface;
5
6
/**
7
 * Class Ellipse
8
 * The 'ellipse' element defines an ellipse which is axis-aligned with the current user coordinate system based on a
9
 * center point and two radii.
10
 *
11
 * @link    https://www.w3.org/TR/SVG11/shapes.html#EllipseElement
12
 *
13
 * @property float rx
14
 * @property float $ry
15
 *
16
 * @package nstdio\svg\shape
17
 * @author  Edgar Asatryan <[email protected]>
18
 */
19
class Ellipse extends RoundedShape
20
{
21
    public function __construct(ElementInterface $parent, $cx, $cy, $rx, $ry)
22
    {
23
        parent::__construct($parent, $cx, $cy);
24
25
        $this->rx = $rx;
26
        $this->ry = $ry;
27
    }
28
29
    public function getName()
30
    {
31
        return 'ellipse';
32
    }
33
34
    public function getBoundingBox()
35
    {
36
        return [
37
            'width' => 2 * $this->rx,
38
            'height' => 2 * $this->ry,
39
            'x' => abs($this->cx - $this->rx),
40
            'y' => abs($this->cy - $this->ry),
41
        ];
42
    }
43
}