@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | * @param array $campos |
36 | 36 | * @return Document |
37 | 37 | */ |
38 | - public static function createDocumentFromArray(array $campos = []) |
|
38 | + public static function createDocumentFromArray(array $campos = [ ]) |
|
39 | 39 | { |
40 | 40 | $document = new Document(); |
41 | - $document->setType(strlen($campos['documento']) === 11 ? Document::CPF : Document::CNPJ); |
|
42 | - $document->setNumber((int) $campos['documento']); |
|
41 | + $document->setType(strlen($campos[ 'documento' ]) === 11 ? Document::CPF : Document::CNPJ); |
|
42 | + $document->setNumber((int) $campos[ 'documento' ]); |
|
43 | 43 | |
44 | 44 | return $document; |
45 | 45 | } |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | * @param array $campos |
49 | 49 | * @return Customer |
50 | 50 | */ |
51 | - public static function createCustomerFromArray(array $campos = []) |
|
51 | + public static function createCustomerFromArray(array $campos = [ ]) |
|
52 | 52 | { |
53 | 53 | $customer = new Customer(); |
54 | - $customer->setCode((int) $campos['cliente']); |
|
55 | - $customer->setIdentityNumber((int) $campos['identificador']); |
|
54 | + $customer->setCode((int) $campos[ 'cliente' ]); |
|
55 | + $customer->setIdentityNumber((int) $campos[ 'identificador' ]); |
|
56 | 56 | |
57 | 57 | return $customer; |
58 | 58 | } |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * @param array $campos |
62 | 62 | * @return Charge |
63 | 63 | */ |
64 | - public static function createChargeFromArray(array $campos = []) |
|
64 | + public static function createChargeFromArray(array $campos = [ ]) |
|
65 | 65 | { |
66 | 66 | $charge = new Charge(); |
67 | - $charge->setCharging($campos['cobranca']); |
|
67 | + $charge->setCharging($campos[ 'cobranca' ]); |
|
68 | 68 | $charge->setOccurrence(self::createOccurrenceFromArray($campos)); |
69 | 69 | |
70 | 70 | return $charge; |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | * @param array $campos |
75 | 75 | * @return ConsumerUnity |
76 | 76 | */ |
77 | - public static function createConsumerUnityFromArray(array $campos = []) |
|
77 | + public static function createConsumerUnityFromArray(array $campos = [ ]) |
|
78 | 78 | { |
79 | 79 | $consumerUnity = new ConsumerUnity(); |
80 | 80 | |
81 | 81 | if (array_key_exists('energia', $campos)) { |
82 | - $leitura = DateTime::createFromFormat('dmY', $campos['energia']['leitura']); |
|
83 | - $vencimento = DateTime::createFromFormat('dmY', $campos['energia']['vencimento']); |
|
82 | + $leitura = DateTime::createFromFormat('dmY', $campos[ 'energia' ][ 'leitura' ]); |
|
83 | + $vencimento = DateTime::createFromFormat('dmY', $campos[ 'energia' ][ 'vencimento' ]); |
|
84 | 84 | |
85 | 85 | $consumerUnity->setRead($leitura); |
86 | 86 | $consumerUnity->setMaturity($vencimento); |
87 | - $consumerUnity->setNumber($campos['energia']['numero']); |
|
88 | - $consumerUnity->setCode($campos['energia']['concessionaria']); |
|
87 | + $consumerUnity->setNumber($campos[ 'energia' ][ 'numero' ]); |
|
88 | + $consumerUnity->setCode($campos[ 'energia' ][ 'concessionaria' ]); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $consumerUnity; |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | * @param array $campos |
96 | 96 | * @return Occurrence |
97 | 97 | */ |
98 | - public static function createOccurrenceFromArray(array $campos = []) |
|
98 | + public static function createOccurrenceFromArray(array $campos = [ ]) |
|
99 | 99 | { |
100 | 100 | $occurrence = new Occurrence(); |
101 | 101 | |
102 | 102 | if (array_key_exists('ocorrencia', $campos)) { |
103 | - $occurrence->setType($campos['ocorrencia']); |
|
103 | + $occurrence->setType($campos[ 'ocorrencia' ]); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | return $occurrence; |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | * @param array $campos |
125 | 125 | * @return Person |
126 | 126 | */ |
127 | - public static function createPersonFromArray(array $campos = []) |
|
127 | + public static function createPersonFromArray(array $campos = [ ]) |
|
128 | 128 | { |
129 | 129 | $person = new Person(); |
130 | - $person->setName($campos['nome']); |
|
131 | - $person->setCellPhone(self::createPhone($campos['celular'], Phone::CELLPHONE)); |
|
132 | - $person->setHomePhone(self::createPhone($campos['telefone1'], Phone::TELEPHONE)); |
|
133 | - $person->setHomePhoneSecondary(self::createPhone($campos['telefone2'], Phone::TELEPHONE)); |
|
134 | - $person->setDocument(self::createDocumentFromArray($campos['comprador'])); |
|
135 | - $person->setEmail($campos['email']); |
|
136 | - $person->setFatherName($campos['pai']); |
|
137 | - $person->setMotherName($campos['mae']); |
|
130 | + $person->setName($campos[ 'nome' ]); |
|
131 | + $person->setCellPhone(self::createPhone($campos[ 'celular' ], Phone::CELLPHONE)); |
|
132 | + $person->setHomePhone(self::createPhone($campos[ 'telefone1' ], Phone::TELEPHONE)); |
|
133 | + $person->setHomePhoneSecondary(self::createPhone($campos[ 'telefone2' ], Phone::TELEPHONE)); |
|
134 | + $person->setDocument(self::createDocumentFromArray($campos[ 'comprador' ])); |
|
135 | + $person->setEmail($campos[ 'email' ]); |
|
136 | + $person->setFatherName($campos[ 'pai' ]); |
|
137 | + $person->setMotherName($campos[ 'mae' ]); |
|
138 | 138 | |
139 | 139 | return $person; |
140 | 140 | } |
@@ -143,17 +143,17 @@ discard block |
||
143 | 143 | * @param array $campos |
144 | 144 | * @return Holder |
145 | 145 | */ |
146 | - public static function createHolderFromArray(array $campos = []) |
|
146 | + public static function createHolderFromArray(array $campos = [ ]) |
|
147 | 147 | { |
148 | 148 | $person = new Holder(); |
149 | 149 | |
150 | 150 | if (array_key_exists('titular', $campos)) { |
151 | - $person->setName($campos['titular']['nome']); |
|
152 | - $person->setCellPhone($campos['titular']['celular']); |
|
153 | - $person->setDocument(self::createDocumentFromArray($campos['titular'])); |
|
154 | - $person->setEmail($campos['titular']['email']); |
|
155 | - $person->setFatherName($campos['titular']['pai']); |
|
156 | - $person->setMotherName($campos['titular']['mae']); |
|
151 | + $person->setName($campos[ 'titular' ][ 'nome' ]); |
|
152 | + $person->setCellPhone($campos[ 'titular' ][ 'celular' ]); |
|
153 | + $person->setDocument(self::createDocumentFromArray($campos[ 'titular' ])); |
|
154 | + $person->setEmail($campos[ 'titular' ][ 'email' ]); |
|
155 | + $person->setFatherName($campos[ 'titular' ][ 'pai' ]); |
|
156 | + $person->setMotherName($campos[ 'titular' ][ 'mae' ]); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return $person; |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | * @param array $campos |
164 | 164 | * @return Address |
165 | 165 | */ |
166 | - public static function createAddressFromArray(array $campos = []) |
|
166 | + public static function createAddressFromArray(array $campos = [ ]) |
|
167 | 167 | { |
168 | 168 | $address = new Address(); |
169 | - $address->setNumber($campos['numero']); |
|
170 | - $address->setAddress($campos['logradouro']); |
|
171 | - $address->setComplement($campos['complemento']); |
|
172 | - $address->setDistrict($campos['bairro']); |
|
173 | - $address->setPostalCode($campos['cep']); |
|
174 | - $address->setCity($campos['cidade']); |
|
175 | - $address->setState($campos['uf']); |
|
169 | + $address->setNumber($campos[ 'numero' ]); |
|
170 | + $address->setAddress($campos[ 'logradouro' ]); |
|
171 | + $address->setComplement($campos[ 'complemento' ]); |
|
172 | + $address->setDistrict($campos[ 'bairro' ]); |
|
173 | + $address->setPostalCode($campos[ 'cep' ]); |
|
174 | + $address->setCity($campos[ 'cidade' ]); |
|
175 | + $address->setState($campos[ 'uf' ]); |
|
176 | 176 | |
177 | 177 | return $address; |
178 | 178 | } |
@@ -181,27 +181,27 @@ discard block |
||
181 | 181 | * @param array $campos |
182 | 182 | * @return BankAccount |
183 | 183 | */ |
184 | - public static function createBankAccountFromArray(array $campos = []) |
|
184 | + public static function createBankAccountFromArray(array $campos = [ ]) |
|
185 | 185 | { |
186 | 186 | $holder = new Holder(); |
187 | 187 | $bank = new Bank(); |
188 | 188 | $account = new BankAccount($bank, $holder); |
189 | 189 | |
190 | 190 | if (array_key_exists('banco', $campos)) { |
191 | - $bank->setAgency($campos['banco']['agencia']); |
|
192 | - $bank->setDigit($campos['banco']['digito']); |
|
193 | - $bank->setCode($campos['banco']['codigo']); |
|
191 | + $bank->setAgency($campos[ 'banco' ][ 'agencia' ]); |
|
192 | + $bank->setDigit($campos[ 'banco' ][ 'digito' ]); |
|
193 | + $bank->setCode($campos[ 'banco' ][ 'codigo' ]); |
|
194 | 194 | |
195 | - $account->setDigit($campos['banco']['conta']['digito']); |
|
196 | - $account->setNumber($campos['banco']['conta']['numero']); |
|
197 | - $account->setOperation($campos['banco']['conta']['operacao']); |
|
195 | + $account->setDigit($campos[ 'banco' ][ 'conta' ][ 'digito' ]); |
|
196 | + $account->setNumber($campos[ 'banco' ][ 'conta' ][ 'numero' ]); |
|
197 | + $account->setOperation($campos[ 'banco' ][ 'conta' ][ 'operacao' ]); |
|
198 | 198 | |
199 | - if (array_key_exists('seguro', $campos['banco']['conta'])) { |
|
200 | - $account->setSecurity($campos['banco']['conta']['seguro']); |
|
199 | + if (array_key_exists('seguro', $campos[ 'banco' ][ 'conta' ])) { |
|
200 | + $account->setSecurity($campos[ 'banco' ][ 'conta' ][ 'seguro' ]); |
|
201 | 201 | } |
202 | 202 | |
203 | - if (array_key_exists('titular', $campos['banco']['conta'])) { |
|
204 | - $account->setHolder(self::createHolderFromArray($campos['banco']['conta']['titular'])); |
|
203 | + if (array_key_exists('titular', $campos[ 'banco' ][ 'conta' ])) { |
|
204 | + $account->setHolder(self::createHolderFromArray($campos[ 'banco' ][ 'conta' ][ 'titular' ])); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
@@ -212,24 +212,24 @@ discard block |
||
212 | 212 | * @param array $campos |
213 | 213 | * @return Purchaser |
214 | 214 | */ |
215 | - public static function createPurchaserFromArray(array $campos = []) |
|
215 | + public static function createPurchaserFromArray(array $campos = [ ]) |
|
216 | 216 | { |
217 | - $purchaser = new Purchaser(); |
|
217 | + $purchaser = new Purchaser(); |
|
218 | 218 | |
219 | 219 | if (array_key_exists('comprador', $campos)) { |
220 | - $document = self::createDocumentFromArray($campos['comprador']); |
|
221 | - $address = self::createAddressFromArray($campos['comprador']['endereco']); |
|
222 | - $birth = DateTime::createFromFormat('dmY', $campos['comprador']['nascimento']); |
|
223 | - |
|
224 | - $purchaser->setName($campos['comprador']['nome']); |
|
225 | - $purchaser->setCellPhone(self::createPhone($campos['comprador']['celular'], Phone::CELLPHONE)); |
|
226 | - $purchaser->setHomePhone(self::createPhone($campos['comprador']['telefone1'], Phone::TELEPHONE)); |
|
227 | - $purchaser->setHomePhoneSecondary(self::createPhone($campos['comprador']['telefone2'], Phone::TELEPHONE)); |
|
220 | + $document = self::createDocumentFromArray($campos[ 'comprador' ]); |
|
221 | + $address = self::createAddressFromArray($campos[ 'comprador' ][ 'endereco' ]); |
|
222 | + $birth = DateTime::createFromFormat('dmY', $campos[ 'comprador' ][ 'nascimento' ]); |
|
223 | + |
|
224 | + $purchaser->setName($campos[ 'comprador' ][ 'nome' ]); |
|
225 | + $purchaser->setCellPhone(self::createPhone($campos[ 'comprador' ][ 'celular' ], Phone::CELLPHONE)); |
|
226 | + $purchaser->setHomePhone(self::createPhone($campos[ 'comprador' ][ 'telefone1' ], Phone::TELEPHONE)); |
|
227 | + $purchaser->setHomePhoneSecondary(self::createPhone($campos[ 'comprador' ][ 'telefone2' ], Phone::TELEPHONE)); |
|
228 | 228 | $purchaser->setDocument($document); |
229 | - $purchaser->setEmail(self::createEmail($campos['comprador']['email'])); |
|
229 | + $purchaser->setEmail(self::createEmail($campos[ 'comprador' ][ 'email' ])); |
|
230 | 230 | $purchaser->setBirth($birth); |
231 | 231 | $purchaser->setAddress($address); |
232 | - $purchaser->setPerson($campos['comprador']['pessoa']); |
|
232 | + $purchaser->setPerson($campos[ 'comprador' ][ 'pessoa' ]); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | return $purchaser; |
@@ -248,15 +248,15 @@ discard block |
||
248 | 248 | * @param array $campos |
249 | 249 | * @return CreditCard |
250 | 250 | */ |
251 | - public static function createCreditCardFromArray(array $campos = []) |
|
251 | + public static function createCreditCardFromArray(array $campos = [ ]) |
|
252 | 252 | { |
253 | 253 | $creditCard = new CreditCard(); |
254 | 254 | |
255 | 255 | if (array_key_exists('cartao', $campos)) { |
256 | - $creditCard->setSecurityNumber($campos['cartao']['seguranca']); |
|
257 | - $creditCard->setValidate(DateTime::createFromFormat('mY', $campos['cartao']['validade'])); |
|
258 | - $creditCard->setNumber($campos['cartao']['numero']); |
|
259 | - $creditCard->setFlag($campos['cartao']['bandeira']); |
|
256 | + $creditCard->setSecurityNumber($campos[ 'cartao' ][ 'seguranca' ]); |
|
257 | + $creditCard->setValidate(DateTime::createFromFormat('mY', $campos[ 'cartao' ][ 'validade' ])); |
|
258 | + $creditCard->setNumber($campos[ 'cartao' ][ 'numero' ]); |
|
259 | + $creditCard->setFlag($campos[ 'cartao' ][ 'bandeira' ]); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | return $creditCard; |
@@ -266,26 +266,26 @@ discard block |
||
266 | 266 | * @param array $campos |
267 | 267 | * @return \SplFixedArray |
268 | 268 | */ |
269 | - public static function createParcelsFromArray(array $campos = []) |
|
269 | + public static function createParcelsFromArray(array $campos = [ ]) |
|
270 | 270 | { |
271 | - $parcels = new Parcels(count($campos['parcelas'])); |
|
271 | + $parcels = new Parcels(count($campos[ 'parcelas' ])); |
|
272 | 272 | $key = 1; |
273 | 273 | |
274 | - foreach ($campos['parcelas'] as $parcela) { |
|
274 | + foreach ($campos[ 'parcelas' ] as $parcela) { |
|
275 | 275 | /* @var $maturity \DateTime */ |
276 | - $maturity = DateTime::createFromFormat('dmY', $parcela['vencimento']); |
|
276 | + $maturity = DateTime::createFromFormat('dmY', $parcela[ 'vencimento' ]); |
|
277 | 277 | |
278 | 278 | $parcelOne = new Parcel(); |
279 | 279 | $parcelOne->setKey($key); |
280 | - $parcelOne->setPrice($parcela['valor']); |
|
281 | - $parcelOne->setQuantity($parcela['quantidade']); |
|
280 | + $parcelOne->setPrice($parcela[ 'valor' ]); |
|
281 | + $parcelOne->setQuantity($parcela[ 'quantidade' ]); |
|
282 | 282 | |
283 | 283 | if ($maturity) { |
284 | 284 | $parcelOne->setMaturity($maturity); |
285 | 285 | } |
286 | 286 | |
287 | 287 | if (array_key_exists('situacao', $parcela)) { |
288 | - $parcelOne->setStatus($parcela['situacao']); |
|
288 | + $parcelOne->setStatus($parcela[ 'situacao' ]); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | $parcels->addParcel($parcelOne); |
@@ -300,16 +300,16 @@ discard block |
||
300 | 300 | * @param array $campos |
301 | 301 | * @return Seller |
302 | 302 | */ |
303 | - public static function createSellerFromArray(array $campos = []) |
|
303 | + public static function createSellerFromArray(array $campos = [ ]) |
|
304 | 304 | { |
305 | 305 | $seller = new Seller(); |
306 | 306 | |
307 | 307 | if (array_key_exists('vendedor', $campos)) { |
308 | 308 | $seller = new Seller(); |
309 | - $seller->setCode($campos['vendedor']['codigo']); |
|
310 | - $seller->setName($campos['vendedor']['nome']); |
|
311 | - $seller->setDocument(static::createDocumentFromArray($campos['vendedor'])); |
|
312 | - $seller->setAddress(static::createAddressFromArray($campos['vendedor']['endereco'])); |
|
309 | + $seller->setCode($campos[ 'vendedor' ][ 'codigo' ]); |
|
310 | + $seller->setName($campos[ 'vendedor' ][ 'nome' ]); |
|
311 | + $seller->setDocument(static::createDocumentFromArray($campos[ 'vendedor' ])); |
|
312 | + $seller->setAddress(static::createAddressFromArray($campos[ 'vendedor' ][ 'endereco' ])); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | return $seller; |
@@ -319,12 +319,12 @@ discard block |
||
319 | 319 | * @param array $campos |
320 | 320 | * @return Authorization |
321 | 321 | */ |
322 | - public static function createAuthorizationFromArray(array $campos = []) |
|
322 | + public static function createAuthorizationFromArray(array $campos = [ ]) |
|
323 | 323 | { |
324 | 324 | $authorization = new Authorization(); |
325 | 325 | |
326 | 326 | if (array_key_exists('autorizacao', $campos)) { |
327 | - $authorization->setNumber($campos['autorizacao']); |
|
327 | + $authorization->setNumber($campos[ 'autorizacao' ]); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | return $authorization; |
@@ -334,13 +334,13 @@ discard block |
||
334 | 334 | * @param array $campos |
335 | 335 | * @return Billet |
336 | 336 | */ |
337 | - public static function createBilletFromArray(array $campos = []) |
|
337 | + public static function createBilletFromArray(array $campos = [ ]) |
|
338 | 338 | { |
339 | 339 | $billet = new Billet(); |
340 | 340 | |
341 | 341 | if (array_key_exists('boleto', $campos)) { |
342 | - $billet->setBankAccount(self::createBankAccountFromArray($campos['boleto'])); |
|
343 | - $billet->setNumber((int) $campos['boleto']['documento']); |
|
342 | + $billet->setBankAccount(self::createBankAccountFromArray($campos[ 'boleto' ])); |
|
343 | + $billet->setNumber((int) $campos[ 'boleto' ][ 'documento' ]); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | return $billet; |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * @param array $campos |
353 | 353 | * @return Detail |
354 | 354 | */ |
355 | - public static function createDetailFromArray(array $campos = []) |
|
355 | + public static function createDetailFromArray(array $campos = [ ]) |
|
356 | 356 | { |
357 | 357 | $sequence = new Sequence(); |
358 | 358 | $customer = self::createCustomerFromArray($campos); |