1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ipag\Sdk\Model; |
4
|
|
|
|
5
|
|
|
use Ipag\Sdk\Util\StateUtil; |
6
|
|
|
use Ipag\Sdk\Model\Schema\Schema; |
7
|
|
|
use Ipag\Sdk\Model\Schema\Mutator; |
8
|
|
|
use Ipag\Sdk\Model\Schema\SchemaBuilder; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Address Class |
12
|
|
|
* |
13
|
|
|
* Classe responsável por representar o recurso Address. |
14
|
|
|
*/ |
15
|
|
|
final class Address extends Model |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @param array $data |
19
|
|
|
* array de dados do Address. |
20
|
|
|
* |
21
|
|
|
* + [`'street'`] string (opcional). |
22
|
|
|
* + [`'number'`] string (opcional). |
23
|
|
|
* + [`'district'`] string (opcional). |
24
|
|
|
* + [`'complement'`] string (opcional). |
25
|
|
|
* + [`'city'`] string (opcional). |
26
|
|
|
* + [`'state'`] string (opcional). |
27
|
|
|
* + [`'zipcode'`] string (opcional). |
28
|
|
|
*/ |
29
|
|
|
public function __construct(?array $data = []) |
30
|
|
|
{ |
31
|
|
|
parent::__construct($data); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function schema(SchemaBuilder $schema): Schema |
35
|
|
|
{ |
36
|
|
|
$schema->string('street')->nullable(); |
37
|
|
|
$schema->string('number')->nullable(); |
38
|
|
|
$schema->string('district')->nullable(); |
39
|
|
|
$schema->string('complement')->nullable(); |
40
|
|
|
$schema->string('city')->nullable(); |
41
|
|
|
$schema->string('state')->nullable(); |
42
|
|
|
$schema->string('zipcode')->nullable(); |
43
|
|
|
|
44
|
|
|
return $schema->build(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function street(): Mutator |
48
|
|
|
{ |
49
|
|
|
return new Mutator( |
50
|
|
|
null, |
51
|
|
|
fn ($value) => strval($value) |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Retorna o valor da propriedade street. |
57
|
|
|
* |
58
|
|
|
* @return string|null |
59
|
|
|
*/ |
60
|
|
|
public function getStreet(): ?string |
61
|
|
|
{ |
62
|
|
|
return $this->get('street'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Seta o valor da propriedade street. |
67
|
|
|
* |
68
|
|
|
* @param string|null $street |
69
|
|
|
* @return self |
70
|
|
|
*/ |
71
|
|
|
public function setStreet(?string $street): self |
72
|
|
|
{ |
73
|
|
|
$this->set('street', $street); |
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function number(): Mutator |
78
|
|
|
{ |
79
|
|
|
return new Mutator( |
80
|
|
|
null, |
81
|
|
|
fn ($value) => strval($value) |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Retorna o valor da propriedade number. |
87
|
|
|
* |
88
|
|
|
* @return string|null |
89
|
|
|
*/ |
90
|
|
|
public function getNumber(): ?string |
91
|
|
|
{ |
92
|
|
|
return $this->get('number'); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Seta o valor da propriedade number. |
97
|
|
|
* |
98
|
|
|
* @param string|null $number |
99
|
|
|
* @return self |
100
|
|
|
*/ |
101
|
|
|
public function setNumber(?string $number): self |
102
|
|
|
{ |
103
|
|
|
$this->set('number', $number); |
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function district(): Mutator |
108
|
|
|
{ |
109
|
|
|
return new Mutator(null, fn ($value) => strval($value)); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Retorna o valor da propriedade district. |
114
|
|
|
* |
115
|
|
|
* @return string|null |
116
|
|
|
*/ |
117
|
|
|
public function getDistrict(): ?string |
118
|
|
|
{ |
119
|
|
|
return $this->get('district'); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Seta o valor da propriedade district. |
124
|
|
|
* |
125
|
|
|
* @param string|null $district |
126
|
|
|
* @return self |
127
|
|
|
*/ |
128
|
|
|
public function setDistrict(?string $district): self |
129
|
|
|
{ |
130
|
|
|
$this->set('district', $district); |
131
|
|
|
return $this; |
132
|
|
|
} |
133
|
|
|
public function complement(): Mutator |
134
|
|
|
{ |
135
|
|
|
return new Mutator(null, fn ($value) => strval($value)); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Retorna o valor da propriedade complement. |
140
|
|
|
* |
141
|
|
|
* @return string|null |
142
|
|
|
*/ |
143
|
|
|
public function getComplement(): ?string |
144
|
|
|
{ |
145
|
|
|
return $this->get('complement'); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Seta o valor da propriedade complement. |
150
|
|
|
* |
151
|
|
|
* @param string|null $complement |
152
|
|
|
* @return self |
153
|
|
|
*/ |
154
|
|
|
public function setComplement(?string $complement): self |
155
|
|
|
{ |
156
|
|
|
$this->set('complement', $complement); |
157
|
|
|
return $this; |
158
|
|
|
} |
159
|
|
|
public function city(): Mutator |
160
|
|
|
{ |
161
|
|
|
return new Mutator(null, fn ($value) => strval($value)); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Retorna o valor da propriedade city. |
166
|
|
|
* |
167
|
|
|
* @return string|null |
168
|
|
|
*/ |
169
|
|
|
public function getCity(): ?string |
170
|
|
|
{ |
171
|
|
|
return $this->get('city'); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Seta o valor da propriedade city. |
176
|
|
|
* |
177
|
|
|
* @param string|null $city |
178
|
|
|
* @return self |
179
|
|
|
*/ |
180
|
|
|
public function setCity(?string $city): self |
181
|
|
|
{ |
182
|
|
|
$this->set('city', $city); |
183
|
|
|
return $this; |
184
|
|
|
} |
185
|
|
|
public function state(): Mutator |
186
|
|
|
{ |
187
|
|
|
return new Mutator(null, fn ($value) => !$value ? null : StateUtil::transformState($value)); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Retorna o valor da propriedade state. |
192
|
|
|
* |
193
|
|
|
* @return string|null |
194
|
|
|
*/ |
195
|
|
|
public function getState(): ?string |
196
|
|
|
{ |
197
|
|
|
return $this->get('state'); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Seta o valor da propriedade state. |
202
|
|
|
* |
203
|
|
|
* @param string|null $state |
204
|
|
|
* @return self |
205
|
|
|
*/ |
206
|
|
|
public function setState(?string $state): self |
207
|
|
|
{ |
208
|
|
|
$this->set('state', $state); |
209
|
|
|
return $this; |
210
|
|
|
} |
211
|
|
|
public function zipcode(): Mutator |
212
|
|
|
{ |
213
|
|
|
return new Mutator(null, fn ($value) => strval(preg_replace('/\D/', '', $value))); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* Retorna o valor da propriedade zipcode. |
218
|
|
|
* |
219
|
|
|
* @return string|null |
220
|
|
|
*/ |
221
|
|
|
public function getZipcode(): ?string |
222
|
|
|
{ |
223
|
|
|
return $this->get('zipcode'); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Seta o valor da propriedade zipcode. |
228
|
|
|
* |
229
|
|
|
* @param string|null $zipcode |
230
|
|
|
* @return self |
231
|
|
|
*/ |
232
|
|
|
public function setZipcode(?string $zipcode): self |
233
|
|
|
{ |
234
|
|
|
$this->set('zipcode', $zipcode); |
235
|
|
|
return $this; |
236
|
|
|
} |
237
|
|
|
} |
238
|
|
|
|