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 Address |
23
|
|
|
* |
24
|
|
|
* @package mrcnpdlk\Grandstream\XMLApp\AddressBook\Model |
25
|
|
|
*/ |
26
|
|
|
class Address implements ModelInterface |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
private $addressFirst; |
32
|
|
|
/** |
33
|
|
|
* @var string|null |
34
|
|
|
*/ |
35
|
|
|
private $addressSecond; |
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
private $city; |
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
private $state; |
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
private $zipCode; |
48
|
|
|
/** |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
private $country; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Address constructor. |
55
|
|
|
* |
56
|
|
|
* @param string $address |
57
|
|
|
*/ |
58
|
1 |
|
public function __construct(string $address) |
59
|
|
|
{ |
60
|
1 |
|
$this->addressFirst = $address; |
61
|
1 |
|
$this->addressSecond = null; |
62
|
1 |
|
$this->setCity('a'); |
63
|
1 |
|
$this->setState('a'); |
64
|
1 |
|
$this->setZipCode('a'); |
65
|
1 |
|
$this->setCountry('a'); |
66
|
1 |
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param string $city |
70
|
|
|
* |
71
|
|
|
* @return Address |
72
|
|
|
*/ |
73
|
1 |
|
public function setCity(string $city) |
74
|
|
|
{ |
75
|
1 |
|
$this->city = $city; |
76
|
|
|
|
77
|
1 |
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param string $state |
82
|
|
|
* |
83
|
|
|
* @return Address |
84
|
|
|
*/ |
85
|
1 |
|
public function setState(string $state) |
86
|
|
|
{ |
87
|
1 |
|
$this->state = $state; |
88
|
|
|
|
89
|
1 |
|
return $this; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param string $zipCode |
94
|
|
|
* |
95
|
|
|
* @return Address |
96
|
|
|
*/ |
97
|
1 |
|
public function setZipCode(string $zipCode) |
98
|
|
|
{ |
99
|
1 |
|
$this->zipCode = $zipCode; |
100
|
|
|
|
101
|
1 |
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param string $country |
106
|
|
|
* |
107
|
|
|
* @return Address |
108
|
|
|
*/ |
109
|
1 |
|
public function setCountry(string $country) |
110
|
|
|
{ |
111
|
1 |
|
$this->country = $country; |
112
|
|
|
|
113
|
1 |
|
return $this; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param string $addressFirst First part of address |
118
|
|
|
* @param string|null $addressSecond Second part of address |
119
|
|
|
* |
120
|
|
|
* @return Address |
121
|
|
|
*/ |
122
|
|
|
public function setAddress(string $addressFirst, string $addressSecond = null) |
123
|
|
|
{ |
124
|
|
|
$this->addressFirst = $addressFirst; |
125
|
|
|
$this->addressSecond = $addressSecond; |
126
|
|
|
|
127
|
|
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @return MyXML |
132
|
|
|
*/ |
133
|
1 |
|
public function getXml(): MyXML |
134
|
|
|
{ |
135
|
1 |
|
$oXml = new MyXML('Address'); |
136
|
1 |
|
$oXml->asObject()->addChild('address1', $this->addressFirst); |
137
|
1 |
|
$oXml->asObject()->addChild('address2', $this->addressSecond); |
138
|
1 |
|
$oXml->asObject()->addChild('city', $this->city); |
139
|
1 |
|
$oXml->asObject()->addChild('state', $this->state); |
140
|
1 |
|
$oXml->asObject()->addChild('zipcode', $this->zipCode); |
141
|
1 |
|
$oXml->asObject()->addChild('country', $this->country); |
142
|
|
|
|
143
|
1 |
|
return $oXml; |
144
|
|
|
|
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|