Test Failed
Push — master ( a5a28b...999969 )
by Marcin
02:51
created

DisplayRectangle::getXml()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
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\Display;
16
17
use mrcnpdlk\Grandstream\XMLApp\Application\Model\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 DisplayRectangle extends DisplayAbstract implements ModelInterface
24
{
25
    /**
26
     * DisplayRectangle constructor.
27
     *
28
     * @param \mrcnpdlk\Grandstream\XMLApp\Helper\Rectangle  $oRectangle
29
     * @param \mrcnpdlk\Grandstream\XMLApp\Helper\Point|null $oPoint
30
     */
31
    public function __construct(
32
        Rectangle $oRectangle,
33
        Point $oPoint = null
34
    ) {
35
        parent::__construct($oPoint, $oRectangle);
36
        $this->setColorBorder(new Color(100));
37
    }
38
39
    /**
40
     * @return MyXML
41
     */
42
    public function getXml() : MyXML
43
    {
44
        $oXml = new MyXML('DisplayRectangle');
45
46
        $oXml->asObject()->addAttribute('x', $this->getPoint()->getX());
47
        $oXml->asObject()->addAttribute('y', $this->getPoint()->getY());
48
        $oXml->asObject()->addAttribute('width', $this->getRectangle()->getWidth());
49
        $oXml->asObject()->addAttribute('height', $this->getRectangle()->getHeight());
50
        $oXml->asObject()->addAttribute('bgcolor', $this->getColorBg()->get());
51
        $oXml->asObject()->addAttribute('border-color', $this->getColorBorder()->get());
52
        $oXml->asObject()->addAttribute('color', $this->getColorFont()->get());
53
54
        return $oXml;
55
    }
56
}
57