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

Screen   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 63
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setPage() 0 6 1
A addEvent() 0 6 1
A getXml() 0 13 2
A getPage() 0 4 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
16
namespace mrcnpdlk\Grandstream\XMLApp\Application\Model;
17
18
use mrcnpdlk\Grandstream\XMLApp\Application\ModelInterface;
19
use mrcnpdlk\Grandstream\XMLApp\MyXML;
20
21
/**
22
 * Class Screen
23
 *
24
 * @package mrcnpdlk\Grandstream\XMLApp\Application\Model
25
 */
26
class Screen implements ModelInterface
27
{
28
29
    /**
30
     * Main customization area for XML application content and softkeys
31
     *
32
     * @var Page
33
     */
34
    private $oPage;
35
    /**
36
     * @var Event[]
37
     */
38
    private $tEvents = [];
39
40
    public function __construct(Page $oPage)
41
    {
42
        $this->setPage($oPage);
43
    }
44
45
    /**
46
     * @param Page $oPage
47
     *
48
     * @return Screen
49
     */
50
    public function setPage(Page $oPage)
51
    {
52
        $this->oPage = $oPage;
53
54
        return $this;
55
    }
56
57
    public function addEvent(Event $oEvent)
58
    {
59
        $this->tEvents[] = $oEvent;
60
61
        return $this;
62
    }
63
64
    /**
65
     * @return MyXML
66
     */
67
    public function getXml(): MyXML
68
    {
69
        $oXml = new MyXML('Screen');
70
        $oXml->insertChild($this->getPage()->getXml()->asObject());
71
72
        $oEvents = new MyXML('Events');
73
        foreach ($this->tEvents as $oEvent) {
74
            $oEvents->insertChild($oEvent->getXml()->asObject());
75
        }
76
        $oXml->insertChild($oEvents->asObject());
77
78
        return $oXml;
79
    }
80
81
    /**
82
     * @return Page
83
     */
84
    public function getPage()
85
    {
86
        return $this->oPage;
87
    }
88
}
89