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

Circle   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 6 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
    public function __construct(ElementInterface $parent, $cx, $cy, $r)
16
    {
17
        parent::__construct($parent, $cx, $cy);
18
19
        $this->r = $r;
20
    }
21
22
    public function getName()
23
    {
24
        return 'circle';
25
    }
26
27
    public function getBoundingBox()
28
    {
29
        $r2 = 2 * $this->r;
30
        return [
31
            'width' => $r2,
32
            'height' => $r2,
33
            'x' => abs($this->cx - $this->r),
34
            'y' => abs($this->cx - $this->r),
35
        ];
36
    }
37
}