|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Itau\API\BoleCode; |
|
4
|
|
|
|
|
5
|
|
|
use Itau\API\StringHelper; |
|
6
|
|
|
use Itau\API\TraitEntity; |
|
7
|
|
|
use JsonSerializable; |
|
8
|
|
|
|
|
9
|
|
|
class Endereco implements JsonSerializable |
|
10
|
|
|
{ |
|
11
|
|
|
use TraitEntity; |
|
12
|
|
|
|
|
13
|
|
|
private string $nome_logradouro; |
|
14
|
|
|
private string $nome_bairro; |
|
15
|
|
|
private string $nome_cidade; |
|
16
|
|
|
private string $sigla_UF; |
|
17
|
|
|
private string $numero_CEP; |
|
18
|
|
|
private string $complemento; |
|
19
|
|
|
private string $numero; |
|
20
|
|
|
|
|
21
|
|
|
public function setEndereco( |
|
22
|
|
|
string $rua, string $numero, string $complemento, string $bairro, string $cidade, string $uf, string $cep |
|
23
|
|
|
): self |
|
24
|
|
|
{ |
|
25
|
|
|
$this->nome_logradouro = $this->textClear($rua, 45); |
|
26
|
|
|
$this->nome_bairro = $this->textClear($bairro, 15); |
|
27
|
|
|
$this->nome_cidade = $this->textClear($cidade, 20); |
|
28
|
|
|
$this->sigla_UF = $this->textClear($uf, 2); |
|
29
|
|
|
$this->numero_CEP = preg_replace("/[^0-9]/", "", $cep); |
|
30
|
|
|
$this->complemento = $this->textClear($complemento, 10); |
|
31
|
|
|
$this->numero = $this->textClear($numero, 10); |
|
32
|
|
|
|
|
33
|
|
|
return $this; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function textClear(?string $value, int $count): ?string |
|
37
|
|
|
{ |
|
38
|
|
|
if(empty($value)){ |
|
39
|
|
|
return null; |
|
40
|
|
|
} |
|
41
|
|
|
return mb_substr(StringHelper::removerAcentos($value), 0, $count); |
|
42
|
|
|
} |
|
43
|
|
|
} |