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

ElemRectangle::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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