AddressBook   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 34
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addContact() 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
namespace mrcnpdlk\Grandstream\XMLApp\AddressBook;
16
17
use mrcnpdlk\Grandstream\XMLApp\AddressBook\Model\Contact;
18
use mrcnpdlk\Grandstream\XMLApp\MyXML;
19
20
/**
21
 * Class AddressBook
22
 *
23
 * @package mrcnpdlk\Grandstream\XMLApp\AddressBook
24
 */
25
class AddressBook implements ModelInterface
26
{
27
28
    /**
29
     * @var Contact[]
30
     */
31
    private $tContacts = [];
32
33
34
    /**
35
     * @param Contact $oContact
36
     *
37
     * @return AddressBook
38
     */
39 2
    public function addContact(Contact $oContact)
40
    {
41 2
        $this->tContacts[] = $oContact;
42
43 2
        return $this;
44
    }
45
46
    /**
47
     * @return MyXML
48
     */
49 2
    public function getXml(): MyXML
50
    {
51 2
        $oXml = new MyXML('AddressBook');
52 2
        foreach ($this->tContacts as $oContact) {
53 2
            $oXml->insertChild($oContact->getXml()->asObject());
54
        }
55
56 2
        return $oXml;
57
    }
58
}
59