View::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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\AddressBook;
17
18
19
use mrcnpdlk\Grandstream\XMLApp\AddressBook\Model\Contact;
20
use mrcnpdlk\Grandstream\XMLApp\AddressBook\Model\Phone;
21
22
class View
23
{
24
    /**
25
     * @var AddressBook
26
     */
27
    private $oAddressBook;
28
29
    /**
30
     * View constructor.
31
     */
32 1
    public function __construct()
33
    {
34 1
        $this->oAddressBook = new AddressBook();
35 1
    }
36
37
    /**
38
     * @param string      $lastName
39
     * @param string      $number
40
     * @param string|null $firstName
41
     * @param int         $iAccountId
42
     *
43
     * @return $this
44
     */
45 1
    public function addContact(string $lastName, string $number, string $firstName = null, int $iAccountId = 1)
46
    {
47 1
        $this->oAddressBook->addContact(
48 1
            new Contact($lastName, new Phone($number, $iAccountId), $firstName)
49
        );
50
51 1
        return $this;
52
    }
53
54
    /**
55
     * @return string
56
     */
57 1
    public function asTxt()
58
    {
59 1
        return $this->oAddressBook->getXml()->asText();
60
    }
61
}
62