|
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\Model; |
|
16
|
|
|
|
|
17
|
|
|
use mrcnpdlk\Grandstream\XMLApp\AddressBook\ModelInterface; |
|
18
|
|
|
use mrcnpdlk\Grandstream\XMLApp\MyXML; |
|
19
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Class Contact |
|
23
|
|
|
* |
|
24
|
|
|
* @package mrcnpdlk\Grandstream\XMLApp\AddressBook\Model |
|
25
|
|
|
*/ |
|
26
|
|
|
class Contact implements ModelInterface |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
private $lastName; |
|
32
|
|
|
/** |
|
33
|
|
|
* @var string|null |
|
34
|
|
|
*/ |
|
35
|
|
|
private $firstName = null; |
|
36
|
|
|
/** |
|
37
|
|
|
* @var Address|null |
|
38
|
|
|
*/ |
|
39
|
|
|
private $oAddress = null; |
|
40
|
|
|
/** |
|
41
|
|
|
* @var Phone |
|
42
|
|
|
*/ |
|
43
|
|
|
private $oPhone; |
|
44
|
|
|
/** |
|
45
|
|
|
* @var string|null |
|
46
|
|
|
*/ |
|
47
|
|
|
private $email = null; |
|
48
|
|
|
/** |
|
49
|
|
|
* @var string|null |
|
50
|
|
|
*/ |
|
51
|
|
|
private $department = null; |
|
52
|
|
|
/** |
|
53
|
|
|
* @var string|null |
|
54
|
|
|
*/ |
|
55
|
|
|
private $company = null; |
|
56
|
|
|
/** |
|
57
|
|
|
* Base64 string |
|
58
|
|
|
* |
|
59
|
|
|
* @var string|null |
|
60
|
|
|
*/ |
|
61
|
|
|
private $icon = null; |
|
62
|
|
|
|
|
63
|
2 |
|
public function __construct(string $lastName, Phone $oPhone) |
|
64
|
|
|
{ |
|
65
|
2 |
|
$this->lastName = $lastName; |
|
66
|
2 |
|
$this->oPhone = $oPhone; |
|
67
|
2 |
|
} |
|
68
|
|
|
|
|
69
|
1 |
|
public function setAddress(Address $oAddress) |
|
70
|
|
|
{ |
|
71
|
1 |
|
$this->oAddress = $oAddress; |
|
72
|
1 |
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return MyXML |
|
76
|
|
|
*/ |
|
77
|
2 |
|
public function getXml(): MyXML |
|
78
|
|
|
{ |
|
79
|
2 |
|
$oXml = new MyXML('Contact'); |
|
80
|
2 |
|
$oXml->asObject()->addChild('LastName', $this->lastName); |
|
81
|
2 |
|
$oXml->asObject()->addChild('FirstName', $this->firstName); |
|
82
|
2 |
|
$oXml->asObject()->addChild('Email', $this->email); |
|
83
|
2 |
|
$oXml->asObject()->addChild('Department', $this->department); |
|
84
|
2 |
|
$oXml->asObject()->addChild('Company', $this->company); |
|
85
|
2 |
|
$oXml->asObject()->addChild('Icon', $this->icon); |
|
86
|
|
|
|
|
87
|
|
|
|
|
88
|
2 |
|
$oXml->insertChild($this->oPhone->getXml()->asObject()); |
|
89
|
|
|
|
|
90
|
2 |
|
if ($this->oAddress) { |
|
91
|
1 |
|
$oXml->insertChild($this->oAddress->getXml()->asObject()); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
|
|
95
|
2 |
|
return $oXml; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
} |
|
100
|
|
|
|