Circle::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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
}