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

Circle::getBoundingBox()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
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
}