Contents::getXml()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 5
cp 0
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 6
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\Model\Components\ElemInterface;
19
use mrcnpdlk\Grandstream\XMLApp\Application\ModelInterface;
20
use mrcnpdlk\Grandstream\XMLApp\MyXML;
21
22
class Contents implements ModelInterface
23
{
24
25
    /**
26
     * @var ModelInterface[]
27
     */
28
    private $tElements = [];
29
30
    /**
31
     * Contents constructor.
32
     */
33
    public function __construct()
34
    {
35
    }
36
37
    /**
38
     * @param \mrcnpdlk\Grandstream\XMLApp\Application\Model\Components\ElemInterface $oElement
39
     *
40
     * @return Contents
41
     */
42
    public function addElement(ElemInterface $oElement)
43
    {
44
        $this->tElements[] = $oElement;
45
46
        return $this;
47
    }
48
49
    /**
50
     * @return MyXML
51
     */
52
    public function getXml(): MyXML
53
    {
54
        $oXml = new MyXML('Contents');
55
        foreach ($this->tElements as $oElement) {
56
            $oXml->insertChild($oElement->getXml()->asObject());
57
        }
58
59
        return $oXml;
60
    }
61
}
62