Completed
Push — master ( a4cd9f...0f09a1 )
by Adriano
03:11
created
src/Integracao/ControlPay/Contracts/Venda/CancelarVendaResponse.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,8 +62,9 @@
 block discarded – undo
62 62
     {
63 63
         $this->intencaoVenda = $intencaoVenda;
64 64
 
65
-        if(is_array($this->intencaoVenda))
66
-            $this->intencaoVenda = SerializerHelper::denormalize($this->intencaoVenda, IntencaoVenda::class);
65
+        if(is_array($this->intencaoVenda)) {
66
+                    $this->intencaoVenda = SerializerHelper::denormalize($this->intencaoVenda, IntencaoVenda::class);
67
+        }
67 68
 
68 69
         return $this;
69 70
     }
Please login to merge, or discard this patch.
src/Integracao/ControlPay/API/VendaApi.php 1 patch
Braces   +33 added lines, -24 removed lines patch added patch discarded remove patch
@@ -44,34 +44,39 @@  discard block
 block discarded – undo
44 44
     {
45 45
         try{
46 46
 
47
-            if(empty($venderRequest->getTerminalId()))
48
-                $venderRequest->setTerminalId(
47
+            if(empty($venderRequest->getTerminalId())) {
48
+                            $venderRequest->setTerminalId(
49 49
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID)
50 50
                 );
51
+            }
51 52
 
52
-            if(empty($venderRequest->getFormaPagamentoId()))
53
-                $venderRequest->setFormaPagamentoId(
53
+            if(empty($venderRequest->getFormaPagamentoId())) {
54
+                            $venderRequest->setFormaPagamentoId(
54 55
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID)
55 56
                 );
57
+            }
56 58
 
57
-            if(empty($venderRequest->isAguardarTefIniciarTransacao()))
58
-                $venderRequest->setAguardarTefIniciarTransacao(
59
+            if(empty($venderRequest->isAguardarTefIniciarTransacao())) {
60
+                            $venderRequest->setAguardarTefIniciarTransacao(
59 61
                     boolval(
60 62
                         $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF)
61 63
                     )
62 64
                 );
65
+            }
63 66
 
64 67
             foreach ($venderRequest->getProdutosVendidos() as $key => $produto)
65 68
             {
66
-                if(empty($produto->getId()))
67
-                    $venderRequest->getProdutosVendidos()[$key]->setId(
69
+                if(empty($produto->getId())) {
70
+                                    $venderRequest->getProdutosVendidos()[$key]->setId(
68 71
                         $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID)
69 72
                     );
73
+                }
70 74
 
71
-                if(empty($produto->getQuantidade()))
72
-                    $venderRequest->getProdutosVendidos()[$key]->setQuantidade(
75
+                if(empty($produto->getQuantidade())) {
76
+                                    $venderRequest->getProdutosVendidos()[$key]->setQuantidade(
73 77
                         $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_QTDE)
74 78
                     );
79
+                }
75 80
             }
76 81
 
77 82
             $this->response = $this->_httpClient->post(__FUNCTION__,[
@@ -82,9 +87,9 @@  discard block
 block discarded – undo
82 87
                 $this->response->json(),
83 88
                 Contracts\Venda\VenderResponse::class
84 89
             );
85
-        }catch (RequestException $ex) {
90
+        } catch (RequestException $ex) {
86 91
             $this->requestException($ex);
87
-        }catch (\Exception $ex){
92
+        } catch (\Exception $ex){
88 93
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
89 94
         }
90 95
     }
@@ -99,17 +104,18 @@  discard block
 block discarded – undo
99 104
         try{
100 105
             $response = $this->pedidoApi->insert($venderComPedidoRequest->getPedidoInserirRequest());
101 106
 
102
-            if(empty($response->getPedido()->getId()))
103
-                throw new \Exception("Falha ao inserir pedido");
107
+            if(empty($response->getPedido()->getId())) {
108
+                            throw new \Exception("Falha ao inserir pedido");
109
+            }
104 110
 
105 111
             $venderComPedidoRequest->getInventarioVenderRequest()->setPedidoId(
106 112
                 $response->getPedido()->getId()
107 113
             );
108 114
 
109 115
             return $this->vender($venderComPedidoRequest->getInventarioVenderRequest());
110
-        }catch (RequestException $ex) {
116
+        } catch (RequestException $ex) {
111 117
             $this->requestException($ex);
112
-        }catch (\Exception $ex){
118
+        } catch (\Exception $ex){
113 119
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
114 120
         }
115 121
     }
@@ -123,22 +129,25 @@  discard block
 block discarded – undo
123 129
     {
124 130
         try{
125 131
 
126
-            if(empty($cancelarVendaRequest->getTerminalId()))
127
-                $cancelarVendaRequest->setTerminalId(
132
+            if(empty($cancelarVendaRequest->getTerminalId())) {
133
+                            $cancelarVendaRequest->setTerminalId(
128 134
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID)
129 135
                 );
136
+            }
130 137
 
131
-            if(empty($cancelarVendaRequest->getSenhaTecnica()))
132
-                $cancelarVendaRequest->setSenhaTecnica(
138
+            if(empty($cancelarVendaRequest->getSenhaTecnica())) {
139
+                            $cancelarVendaRequest->setSenhaTecnica(
133 140
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA)
134 141
                 );
142
+            }
135 143
 
136
-            if(empty($cancelarVendaRequest->isAguardarTefIniciarTransacao()))
137
-                $cancelarVendaRequest->setAguardarTefIniciarTransacao(
144
+            if(empty($cancelarVendaRequest->isAguardarTefIniciarTransacao())) {
145
+                            $cancelarVendaRequest->setAguardarTefIniciarTransacao(
138 146
                     boolval(
139 147
                         $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF)
140 148
                     )
141 149
                 );
150
+            }
142 151
 
143 152
 
144 153
             $this->response = $this->_httpClient->post(__FUNCTION__,[
@@ -149,9 +158,9 @@  discard block
 block discarded – undo
149 158
                 $this->response->json(),
150 159
                 Contracts\Venda\CancelarVendaResponse::class
151 160
             );
152
-        }catch (RequestException $ex) {
161
+        } catch (RequestException $ex) {
153 162
             $this->requestException($ex);
154
-        }catch (\Exception $ex){
163
+        } catch (\Exception $ex){
155 164
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
156 165
         }
157 166
     }
Please login to merge, or discard this patch.
src/Integracao/ControlPay/Model/IntencaoVenda.php 1 patch
Braces   +45 added lines, -30 removed lines patch added patch discarded remove patch
@@ -220,8 +220,9 @@  discard block
 block discarded – undo
220 220
     {
221 221
         $this->pessoaVendedor = $pessoaVendedor;
222 222
 
223
-        if(is_array($this->pessoaVendedor))
224
-            $this->pessoaVendedor = SerializerHelper::denormalize($this->pessoaVendedor, Pessoa::class);
223
+        if(is_array($this->pessoaVendedor)) {
224
+                    $this->pessoaVendedor = SerializerHelper::denormalize($this->pessoaVendedor, Pessoa::class);
225
+        }
225 226
 
226 227
         return $this;
227 228
     }
@@ -242,8 +243,9 @@  discard block
 block discarded – undo
242 243
     {
243 244
         $this->pessoaCliente = $pessoaCliente;
244 245
 
245
-        if(is_array($this->pessoaCliente))
246
-            $this->pessoaCliente = SerializerHelper::denormalize($this->pessoaCliente, Pessoa::class);
246
+        if(is_array($this->pessoaCliente)) {
247
+                    $this->pessoaCliente = SerializerHelper::denormalize($this->pessoaCliente, Pessoa::class);
248
+        }
247 249
 
248 250
         return $this;
249 251
     }
@@ -264,8 +266,9 @@  discard block
 block discarded – undo
264 266
     {
265 267
         $this->formaPagamento = $formaPagamento;
266 268
 
267
-        if(is_array($this->formaPagamento))
268
-            $this->formaPagamento = SerializerHelper::denormalize($this->formaPagamento, FormaPagamento::class);
269
+        if(is_array($this->formaPagamento)) {
270
+                    $this->formaPagamento = SerializerHelper::denormalize($this->formaPagamento, FormaPagamento::class);
271
+        }
269 272
 
270 273
         return $this;
271 274
     }
@@ -286,8 +289,9 @@  discard block
 block discarded – undo
286 289
     {
287 290
         $this->terminal = $terminal;
288 291
 
289
-        if(is_array($this->terminal))
290
-            $this->terminal = SerializerHelper::denormalize($this->terminal, Terminal::class);
292
+        if(is_array($this->terminal)) {
293
+                    $this->terminal = SerializerHelper::denormalize($this->terminal, Terminal::class);
294
+        }
291 295
 
292 296
         return $this;
293 297
     }
@@ -308,8 +312,9 @@  discard block
 block discarded – undo
308 312
     {
309 313
         $this->pedido = $pedido;
310 314
 
311
-        if(is_array($this->pedido))
312
-            $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class);
315
+        if(is_array($this->pedido)) {
316
+                    $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class);
317
+        }
313 318
 
314 319
         return $this;
315 320
     }
@@ -330,8 +335,9 @@  discard block
 block discarded – undo
330 335
     {
331 336
         $this->operador = $operador;
332 337
 
333
-        if(is_array($this->operador))
334
-            $this->operador = SerializerHelper::denormalize($this->operador, Operador::class);
338
+        if(is_array($this->operador)) {
339
+                    $this->operador = SerializerHelper::denormalize($this->operador, Operador::class);
340
+        }
335 341
 
336 342
         return $this;
337 343
     }
@@ -352,8 +358,9 @@  discard block
 block discarded – undo
352 358
     {
353 359
         $this->contaRecebimentoLancamento = $contaRecebimentoLancamento;
354 360
 
355
-        if(is_array($this->contaRecebimentoLancamento))
356
-            $this->contaRecebimentoLancamento = SerializerHelper::denormalize($this->contaRecebimentoLancamento, ContaRecebimentoLancamento::class);
361
+        if(is_array($this->contaRecebimentoLancamento)) {
362
+                    $this->contaRecebimentoLancamento = SerializerHelper::denormalize($this->contaRecebimentoLancamento, ContaRecebimentoLancamento::class);
363
+        }
357 364
 
358 365
         return $this;
359 366
     }
@@ -374,8 +381,9 @@  discard block
 block discarded – undo
374 381
     {
375 382
         $this->pagamentoRecorrenteLancamento = $pagamentoRecorrenteLancamento;
376 383
 
377
-        if(is_array($this->pagamentoRecorrenteLancamento))
378
-            $this->pagamentoRecorrenteLancamento = SerializerHelper::denormalize($this->pagamentoRecorrenteLancamento, PagamentoRecorrenteLancamento::class);
384
+        if(is_array($this->pagamentoRecorrenteLancamento)) {
385
+                    $this->pagamentoRecorrenteLancamento = SerializerHelper::denormalize($this->pagamentoRecorrenteLancamento, PagamentoRecorrenteLancamento::class);
386
+        }
379 387
 
380 388
         return $this;
381 389
     }
@@ -396,8 +404,9 @@  discard block
 block discarded – undo
396 404
     {
397 405
         $this->intencaoVendaStatus = $intencaoVendaStatus;
398 406
 
399
-        if(is_array($this->intencaoVendaStatus))
400
-            $this->intencaoVendaStatus = SerializerHelper::denormalize($this->intencaoVendaStatus, IntencaoVendaStatus::class);
407
+        if(is_array($this->intencaoVendaStatus)) {
408
+                    $this->intencaoVendaStatus = SerializerHelper::denormalize($this->intencaoVendaStatus, IntencaoVendaStatus::class);
409
+        }
401 410
 
402 411
         return $this;
403 412
     }
@@ -454,8 +463,9 @@  discard block
 block discarded – undo
454 463
     {
455 464
         $this->data = \DateTime::createFromFormat('d/m/Y H:i:s.u', $data);
456 465
 
457
-        if(!$this->data)
458
-            $this->data = \DateTime::createFromFormat('d/m/Y H:i:s', $data);
466
+        if(!$this->data) {
467
+                    $this->data = \DateTime::createFromFormat('d/m/Y H:i:s', $data);
468
+        }
459 469
 
460 470
         return $this;
461 471
     }
@@ -638,10 +648,11 @@  discard block
 block discarded – undo
638 648
     {
639 649
         //$this->itemProdutos = $itemProdutos;
640 650
 
641
-        if(is_array($itemProdutos))
642
-            foreach ($itemProdutos as $itemProduto) {
651
+        if(is_array($itemProdutos)) {
652
+                    foreach ($itemProdutos as $itemProduto) {
643 653
                 $this->itemProdutos[] = SerializerHelper::denormalize(
644 654
                     $itemProduto, ItemProduto::class);
655
+        }
645 656
             }
646 657
 
647 658
         return $this;
@@ -661,10 +672,11 @@  discard block
 block discarded – undo
661 672
      */
662 673
     public function setPagamentosExterno($pagamentosExterno)
663 674
     {
664
-        if(is_array($pagamentosExterno))
665
-            foreach ($pagamentosExterno as $pagamentoExterno) {
675
+        if(is_array($pagamentosExterno)) {
676
+                    foreach ($pagamentosExterno as $pagamentoExterno) {
666 677
                 $this->pagamentosExterno[] = SerializerHelper::denormalize(
667 678
                     $pagamentoExterno, PagamentoExterno::class);
679
+        }
668 680
             }
669 681
 
670 682
         return $this;
@@ -685,10 +697,11 @@  discard block
 block discarded – undo
685 697
     public function setProdutos($produtos)
686 698
     {
687 699
 
688
-        if(is_array($produtos))
689
-            foreach ($produtos as $produto) {
700
+        if(is_array($produtos)) {
701
+                    foreach ($produtos as $produto) {
690 702
                 $this->produtos[] = SerializerHelper::denormalize(
691 703
                     $produto, ItemProduto::class);
704
+        }
692 705
             }
693 706
 
694 707
         return $this;
@@ -818,8 +831,9 @@  discard block
 block discarded – undo
818 831
     {
819 832
         $this->vendedor = $vendedor;
820 833
 
821
-        if(is_array($this->vendedor))
822
-            $this->vendedor = SerializerHelper::denormalize($this->pessoaVendedor, Pessoa::class);
834
+        if(is_array($this->vendedor)) {
835
+                    $this->vendedor = SerializerHelper::denormalize($this->pessoaVendedor, Pessoa::class);
836
+        }
823 837
 
824 838
         return $this;
825 839
     }
@@ -856,10 +870,11 @@  discard block
 block discarded – undo
856 870
      */
857 871
     public function setPagamentosExternos($pagamentosExternos)
858 872
     {
859
-        if(is_array($pagamentosExternos))
860
-            foreach ($pagamentosExternos as $pagamentoExterno) {
873
+        if(is_array($pagamentosExternos)) {
874
+                    foreach ($pagamentosExternos as $pagamentoExterno) {
861 875
                 $this->pagamentosExternos[] = SerializerHelper::denormalize(
862 876
                     $pagamentoExterno, PagamentoExterno::class);
877
+        }
863 878
             }
864 879
 
865 880
         return $this;
Please login to merge, or discard this patch.