Circle   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 86.67%

Importance

Changes 0
Metric Value
dl 0
loc 30
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 6 1
A create() 0 4 1
A getName() 0 4 1
A getBoundingBox() 0 10 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
}