1 | <?php |
||
38 | class Status implements Node |
||
39 | { |
||
40 | |||
41 | private $ambiente; |
||
42 | private $versao; |
||
43 | private $status; |
||
44 | private $motivo; |
||
45 | private $uf; |
||
|
|||
46 | |||
47 | 30 | public function __construct($status = array()) |
|
51 | |||
52 | /** |
||
53 | * Identificação do Ambiente: |
||
54 | * 1 - Produção |
||
55 | * 2 - Homologação |
||
56 | */ |
||
57 | 22 | public function getAmbiente($normalize = false) |
|
58 | { |
||
59 | 22 | if (!$normalize) { |
|
60 | 18 | return $this->ambiente; |
|
61 | } |
||
62 | 18 | switch ($this->ambiente) { |
|
63 | 18 | case Nota::AMBIENTE_PRODUCAO: |
|
64 | return '1'; |
||
65 | 18 | case Nota::AMBIENTE_HOMOLOGACAO: |
|
66 | 17 | return '2'; |
|
67 | 1 | } |
|
68 | 1 | return $this->ambiente; |
|
69 | } |
||
70 | |||
71 | 30 | public function setAmbiente($ambiente) |
|
72 | { |
||
73 | switch ($ambiente) { |
||
74 | 30 | case '1': |
|
75 | $ambiente = Nota::AMBIENTE_PRODUCAO; |
||
76 | break; |
||
77 | 30 | case '2': |
|
78 | 17 | $ambiente = Nota::AMBIENTE_HOMOLOGACAO; |
|
79 | 17 | break; |
|
80 | } |
||
81 | 30 | $this->ambiente = $ambiente; |
|
82 | 30 | return $this; |
|
83 | } |
||
84 | |||
85 | /** |
||
86 | * Versão do Aplicativo que processou a NF-e |
||
87 | */ |
||
88 | 12 | public function getVersao($normalize = false) |
|
89 | { |
||
90 | 12 | if (!$normalize) { |
|
91 | 11 | return $this->versao; |
|
92 | } |
||
93 | 5 | return $this->versao; |
|
94 | } |
||
95 | |||
96 | 30 | public function setVersao($versao) |
|
101 | |||
102 | /** |
||
103 | * Código do status da mensagem enviada. |
||
104 | */ |
||
105 | 19 | public function getStatus($normalize = false) |
|
106 | { |
||
107 | 19 | if (!$normalize) { |
|
108 | 19 | return $this->status; |
|
109 | } |
||
110 | 5 | return $this->status; |
|
111 | } |
||
112 | |||
113 | 30 | public function setStatus($status) |
|
118 | |||
119 | /** |
||
120 | * Descrição literal do status do serviço solicitado. |
||
121 | */ |
||
122 | 13 | public function getMotivo($normalize = false) |
|
123 | { |
||
124 | 13 | if (!$normalize) { |
|
125 | 12 | return $this->motivo; |
|
126 | } |
||
127 | 5 | return $this->motivo; |
|
128 | } |
||
129 | |||
130 | 30 | public function setMotivo($motivo) |
|
135 | |||
136 | /** |
||
137 | * código da UF de atendimento |
||
138 | */ |
||
139 | 14 | public function getUF($normalize = false) |
|
140 | { |
||
141 | 14 | if (!$normalize || is_numeric($this->uf)) { |
|
142 | 12 | return $this->uf; |
|
143 | } |
||
144 | |||
145 | 4 | $estado = new Estado(); |
|
146 | 4 | $estado->setUF($this->uf); |
|
147 | 4 | $estado->checkCodigos(); |
|
148 | 4 | return $estado->getCodigo(); |
|
149 | } |
||
150 | |||
151 | 30 | public function setUF($uf) |
|
156 | |||
157 | /** |
||
158 | * Gera um número único com 15 dígitos |
||
159 | * @return string Número com 15 dígitos |
||
160 | */ |
||
161 | 16 | public static function genLote() |
|
162 | { |
||
165 | |||
166 | 11 | public function toArray($recursive = false) |
|
176 | |||
177 | 30 | public function fromArray($status = array()) |
|
211 | |||
212 | 5 | public function getNode($name = null) |
|
225 | |||
226 | 18 | public function loadNode($element, $name = null) |
|
267 | } |
||
268 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.