Contents   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 40
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A addElement() 0 6 1
A getXml() 0 9 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
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