Completed
Push — master ( e6cea0...5c122a )
by Marcin
01:53
created

ElemRectangle   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 31
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getXml() 0 13 1
1
<?php
2
/**
3
 * Grandstream-XMLApp
4
 *
5
 * Copyright (c) 2017 pudelek.org.pl
6
 *
7
 * @license MIT License (MIT)
8
 *
9
 * For the full copyright and license information, please view source file
10
 * that is bundled with this package in the file LICENSE
11
 *
12
 * @author  Marcin Pudełek <[email protected]>
13
 */
14
15
namespace mrcnpdlk\Grandstream\XMLApp\Application\Model\Components;
16
17
use mrcnpdlk\Grandstream\XMLApp\Application\ModelInterface;
18
use mrcnpdlk\Grandstream\XMLApp\Helper\Color;
19
use mrcnpdlk\Grandstream\XMLApp\Helper\Point;
20
use mrcnpdlk\Grandstream\XMLApp\Helper\Rectangle;
21
use mrcnpdlk\Grandstream\XMLApp\MyXML;
22
23
class ElemRectangle extends ElemAbstract implements ModelInterface, ElemInterface
24
{
25
    /**
26
     * ElemRectangle constructor.
27
     *
28
     * @param int $iWidth
29
     * @param int $iHeight
30
     */
31
    public function __construct(int $iWidth, int $iHeight)
32
    {
33
        parent::__construct(new Point(0, 0), new Rectangle($iWidth, $iHeight));
34
        $this->setColorBorder(new Color(100));
35
    }
36
37
    /**
38
     * @return MyXML
39
     */
40
    public function getXml(): MyXML
41
    {
42
        $oXml = new MyXML('DisplayRectangle');
43
44
        $oXml->asObject()->addAttribute('x', $this->getPoint()->getX());
45
        $oXml->asObject()->addAttribute('y', $this->getPoint()->getY());
46
        $oXml->asObject()->addAttribute('width', $this->getRectangle()->getWidth());
47
        $oXml->asObject()->addAttribute('height', $this->getRectangle()->getHeight());
48
        $oXml->asObject()->addAttribute('bgcolor', $this->getColorBg()->get());
49
        $oXml->asObject()->addAttribute('border-color', $this->getColorBorder()->get());
50
51
        return $oXml;
52
    }
53
}
54