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

Circle::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 4
crap 2
1
<?php
2
namespace nstdio\svg\shape;
3
4
use nstdio\svg\ElementInterface;
5
6
/**
7
 * Class Circle
8
 *
9
 * @property float $r The circle radius.
10
 * @package nstdio\svg\shape
11
 * @author  Edgar Asatryan <[email protected]>
12
 */
13
class Circle extends RoundedShape
14
{
15 21
    public function __construct(ElementInterface $parent, $cx, $cy, $r)
16
    {
17 21
        parent::__construct($parent, $cx, $cy);
18
19 21
        $this->r = $r;
20 21
    }
21
22
    public static function create(ElementInterface $parent, $cx, $cy, $r)
23
    {
24
        return new Circle($parent, $cx, $cy, $r);
25
    }
26
27 21
    public function getName()
28
    {
29 21
        return 'circle';
30
    }
31
32 2
    public function getBoundingBox()
33
    {
34 2
        $r2 = 2 * $this->r;
35
        return [
36 2
            'width' => $r2,
37 2
            'height' => $r2,
38 2
            'x' => abs($this->cx - $this->r),
39 2
            'y' => abs($this->cx - $this->r),
40 2
        ];
41
    }
42
}