Test Failed
Push — master ( b95750...93ce75 )
by Edgar
03:22
created

Ellipse   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 86.67%

Importance

Changes 0
Metric Value
dl 0
loc 48
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1
ccs 13
cts 15
cp 0.8667
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A create() 0 4 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
    /**
22
     * Ellipse constructor.
23
     *
24
     * @param ElementInterface $parent
25
     * @param                  $cx
26
     * @param                  $cy
27
     * @param                  $rx
28
     * @param                  $ry
29
     */
30 8
    public function __construct(ElementInterface $parent, $cx, $cy, $rx, $ry)
31
    {
32 8
        parent::__construct($parent, $cx, $cy);
33
34 8
        $this->rx = $rx;
35 8
        $this->ry = $ry;
36 8
    }
37
38
    /**
39
     * @param ElementInterface $parent
40
     * @param                  $cx
41
     * @param                  $cy
42
     * @param                  $rx
43
     * @param                  $ry
44
     *
45
     * @return Ellipse
46
     */
47
    public static function create(ElementInterface $parent, $cx, $cy, $rx, $ry)
48
    {
49
        return new Ellipse($parent, $cx, $cy, $rx, $ry);
50
    }
51
52 8
    public function getName()
53
    {
54 8
        return 'ellipse';
55
    }
56
57 1
    public function getBoundingBox()
58
    {
59
        return [
60 1
            'width'  => 2 * $this->rx,
61 1
            'height' => 2 * $this->ry,
62 1
            'x'      => abs($this->cx - $this->rx),
63 1
            'y'      => abs($this->cy - $this->ry),
64 1
        ];
65
    }
66
}