Completed
Push — master ( 741114...78e68a )
by Adriano
09:10
created
src/Integracao/ControlPay/AbstractAPI.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $this->endpoint = $endpoint;
61 61
         $this->_client = $client;
62 62
 
63
-        if(is_null($this->_client))
63
+        if (is_null($this->_client))
64 64
             $this->_client = new Client();
65 65
 
66 66
         $this->query = new GuzzleHttp\Query();
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 $this->query->set('key', $this->_client->getAuthentication());
73 73
                 break;
74 74
             case BasicAuthentication::class:
75
-                $this->headers['Authorization'] = $this->_client->getAuthentication();
75
+                $this->headers[ 'Authorization' ] = $this->_client->getAuthentication();
76 76
                 break;
77 77
             default:
78 78
                 $this->query->set('key', $this->_client->getAuthentication());
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
     {
104 104
         $this->query = new GuzzleHttp\Query();
105 105
 
106
-        if(isset($this->_httpClient->getDefaultOption()['query']))
107
-            $this->query = $this->_httpClient->getDefaultOption()['query'];
106
+        if (isset($this->_httpClient->getDefaultOption()[ 'query' ]))
107
+            $this->query = $this->_httpClient->getDefaultOption()[ 'query' ];
108 108
 
109 109
         foreach ($params as $key => $value)
110 110
             $this->query->set($key, $value);
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function getQueryParameters()
127 127
     {
128
-        return isset($this->_httpClient->getDefaultOption()['query']) ?
129
-            $this->_httpClient->getDefaultOption()['query'] : [];
128
+        return isset($this->_httpClient->getDefaultOption()[ 'query' ]) ?
129
+            $this->_httpClient->getDefaultOption()[ 'query' ] : [ ];
130 130
     }
131 131
 
132 132
     /**
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function getHeaders()
136 136
     {
137
-        return isset($this->_httpClient->getDefaultOption()['headers']) ?
138
-            $this->_httpClient->getDefaultOption()['headers'] : [];
137
+        return isset($this->_httpClient->getDefaultOption()[ 'headers' ]) ?
138
+            $this->_httpClient->getDefaultOption()[ 'headers' ] : [ ];
139 139
     }
140 140
 
141 141
     /**
Please login to merge, or discard this patch.
src/Integracao/ControlPay/API/IntencaoVendaApi.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function getByPessoaId($pessoaId)
32 32
     {
33
-        try{
34
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
33
+        try {
34
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
35 35
                 'query' => $this->addQueryAdditionalParameters([
36 36
                     'pessoaId' => $pessoaId
37 37
                 ])
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
             );
44 44
         }catch (RequestException $ex) {
45 45
             $this->requestException($ex);
46
-        }catch (\Exception $ex){
46
+        }catch (\Exception $ex) {
47 47
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
48 48
         }
49 49
     }
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function getById($terminalId)
57 57
     {
58
-        try{
59
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
58
+        try {
59
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
60 60
                 'query' => $this->addQueryAdditionalParameters([
61 61
                     'terminalId' => $terminalId
62 62
                 ])
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             );
69 69
         }catch (RequestException $ex) {
70 70
             $this->requestException($ex);
71
-        }catch (\Exception $ex){
71
+        }catch (\Exception $ex) {
72 72
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
73 73
         }
74 74
     }
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function insert(Contracts\Terminal\InsertRequest $insertRequest)
82 82
     {
83
-        try{
84
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
83
+        try {
84
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
85 85
                 'body' => json_encode($insertRequest)
86 86
             ]);
87 87
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
             );
92 92
         }catch (RequestException $ex) {
93 93
             $this->requestException($ex);
94
-        }catch (\Exception $ex){
94
+        }catch (\Exception $ex) {
95 95
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
96 96
         }
97 97
     }
Please login to merge, or discard this patch.
src/Integracao/ControlPay/API/VendaApi.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -42,19 +42,19 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function vender(Contracts\Venda\VenderRequest $venderRequest)
44 44
     {
45
-        try{
45
+        try {
46 46
 
47
-            if(empty($venderRequest->getTerminalId()))
47
+            if (empty($venderRequest->getTerminalId()))
48 48
                 $venderRequest->setTerminalId(
49 49
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID)
50 50
                 );
51 51
 
52
-            if(empty($venderRequest->getFormaPagamentoId()))
52
+            if (empty($venderRequest->getFormaPagamentoId()))
53 53
                 $venderRequest->setFormaPagamentoId(
54 54
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID)
55 55
                 );
56 56
 
57
-            if(empty($venderRequest->isAguardarTefIniciarTransacao()))
57
+            if (empty($venderRequest->isAguardarTefIniciarTransacao()))
58 58
                 $venderRequest->setAguardarTefIniciarTransacao(
59 59
                     boolval(
60 60
                         $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF)
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 
64 64
             foreach ($venderRequest->getProdutosVendidos() as $key => $produto)
65 65
             {
66
-                if(empty($produto->getId()))
67
-                    $venderRequest->getProdutosVendidos()[$key]->setId(
66
+                if (empty($produto->getId()))
67
+                    $venderRequest->getProdutosVendidos()[ $key ]->setId(
68 68
                         $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID)
69 69
                     );
70 70
             }
71 71
 
72
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
72
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
73 73
                 'body' => json_encode($venderRequest),
74 74
             ]);
75 75
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
             );
80 80
         }catch (RequestException $ex) {
81 81
             $this->requestException($ex);
82
-        }catch (\Exception $ex){
82
+        }catch (\Exception $ex) {
83 83
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
84 84
         }
85 85
     }
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function venderComPedido(Contracts\Venda\VenderComPedidoRequest $venderComPedidoRequest)
93 93
     {
94
-        try{
94
+        try {
95 95
             $response = $this->pedidoApi->insert($venderComPedidoRequest->getPedidoInserirRequest());
96 96
 
97
-            if(empty($response->getPedido()->getId()))
97
+            if (empty($response->getPedido()->getId()))
98 98
                 throw new \Exception("Falha ao inserir pedido");
99 99
 
100 100
             $venderComPedidoRequest->getInventarioVenderRequest()->setPedidoId(
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             return $this->vender($venderComPedidoRequest->getInventarioVenderRequest());
105 105
         }catch (RequestException $ex) {
106 106
             $this->requestException($ex);
107
-        }catch (\Exception $ex){
107
+        }catch (\Exception $ex) {
108 108
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
109 109
         }
110 110
     }
@@ -116,19 +116,19 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function cancelarVenda(Contracts\Venda\CancelarVendaRequest $cancelarVendaRequest)
118 118
     {
119
-        try{
119
+        try {
120 120
 
121
-            if(empty($cancelarVendaRequest->getTerminalId()))
121
+            if (empty($cancelarVendaRequest->getTerminalId()))
122 122
                 $cancelarVendaRequest->setTerminalId(
123 123
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID)
124 124
                 );
125 125
 
126
-            if(empty($cancelarVendaRequest->getSenhaTecnica()))
126
+            if (empty($cancelarVendaRequest->getSenhaTecnica()))
127 127
                 $cancelarVendaRequest->setSenhaTecnica(
128 128
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA)
129 129
                 );
130 130
 
131
-            if(empty($cancelarVendaRequest->isAguardarTefIniciarTransacao()))
131
+            if (empty($cancelarVendaRequest->isAguardarTefIniciarTransacao()))
132 132
                 $cancelarVendaRequest->setAguardarTefIniciarTransacao(
133 133
                     boolval(
134 134
                         $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF)
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                 );
137 137
 
138 138
 
139
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
139
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
140 140
                 'body' => json_encode($cancelarVendaRequest),
141 141
             ]);
142 142
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
             );
147 147
         }catch (RequestException $ex) {
148 148
             $this->requestException($ex);
149
-        }catch (\Exception $ex){
149
+        }catch (\Exception $ex) {
150 150
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
151 151
         }
152 152
     }
Please login to merge, or discard this patch.
src/Integracao/ControlPay/Contracts/Venda/CancelarVendaResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
     {
63 63
         $this->intencaoVenda = $intencaoVenda;
64 64
 
65
-        if(is_array($this->intencaoVenda))
65
+        if (is_array($this->intencaoVenda))
66 66
             $this->intencaoVenda = SerializerHelper::denormalize($this->intencaoVenda, IntencaoVenda::class);
67 67
 
68 68
         return $this;
Please login to merge, or discard this patch.
src/Integracao/ControlPay/Client.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function getParameter($key)
72 72
     {
73
-        return isset($this->_params[$key]) ? $this->_params[$key] : null;
73
+        return isset($this->_params[ $key ]) ? $this->_params[ $key ] : null;
74 74
     }
75 75
 
76 76
     /**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function setParameter($key, $value)
84 84
     {
85
-        $this->_params[$key] = $value;
85
+        $this->_params[ $key ] = $value;
86 86
         $this->loadParameters($this->_params, $this->authentication);
87 87
         return $this;
88 88
     }
@@ -96,23 +96,23 @@  discard block
 block discarded – undo
96 96
      */
97 97
     private function loadParameters($params, IAuthentication $authentication = null)
98 98
     {
99
-        $this->_params[ControlPayParameterConst::CONTROLPAY_HOST] = getenv('CONTROLPAY_HOST');
100
-        $this->_params[ControlPayParameterConst::CONTROLPAY_TIMEOUT] = getenv('CONTROLPAY_TIMEOUT');
101
-        $this->_params[ControlPayParameterConst::CONTROLPAY_USER] = getenv('CONTROLPAY_USER');
102
-        $this->_params[ControlPayParameterConst::CONTROLPAY_PWD] = getenv('CONTROLPAY_PWD');
103
-        $this->_params[ControlPayParameterConst::CONTROLPAY_KEY] = getenv('CONTROLPAY_KEY');
104
-        $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_PESSOA_ID] = getenv('CONTROLPAY_DEFAULT_PESSOA_ID');
105
-        $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID] = getenv('CONTROLPAY_DEFAULT_TERMINAL_ID');
106
-        $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID] = getenv('CONTROLPAY_DEFAULT_PRODUTO_ID');
107
-        $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID] = getenv('CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID');
108
-        $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF] = getenv('CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF');
109
-        $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA] = getenv('CONTROLPAY_DEFAULT_SENHA_TECNICA');
110
-        $this->_params[ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE] = KeyQueryStringAuthentication::class;
111
-
112
-        if(!is_null($params))
99
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_HOST ] = getenv('CONTROLPAY_HOST');
100
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_TIMEOUT ] = getenv('CONTROLPAY_TIMEOUT');
101
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_USER ] = getenv('CONTROLPAY_USER');
102
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_PWD ] = getenv('CONTROLPAY_PWD');
103
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_KEY ] = getenv('CONTROLPAY_KEY');
104
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_PESSOA_ID ] = getenv('CONTROLPAY_DEFAULT_PESSOA_ID');
105
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID ] = getenv('CONTROLPAY_DEFAULT_TERMINAL_ID');
106
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID ] = getenv('CONTROLPAY_DEFAULT_PRODUTO_ID');
107
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID ] = getenv('CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID');
108
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF ] = getenv('CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF');
109
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA ] = getenv('CONTROLPAY_DEFAULT_SENHA_TECNICA');
110
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE ] = KeyQueryStringAuthentication::class;
111
+
112
+        if (!is_null($params))
113 113
             foreach ($params as $key => $param)
114 114
             {
115
-                if(!in_array($key, [
115
+                if (!in_array($key, [
116 116
                     ControlPayParameterConst::CONTROLPAY_HOST,
117 117
                     ControlPayParameterConst::CONTROLPAY_TIMEOUT,
118 118
                     ControlPayParameterConst::CONTROLPAY_USER,
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
                     throw new \Exception(sprintf("Parâmetro %s inválido", $key));
130 130
             }
131 131
 
132
-        if(!is_null($params) && is_array($params))
132
+        if (!is_null($params) && is_array($params))
133 133
             foreach ($params as $key => $value)
134
-                $this->_params[$key] = $value;
134
+                $this->_params[ $key ] = $value;
135 135
 
136
-        if(is_null($authentication))
136
+        if (is_null($authentication))
137 137
         {
138 138
             $this->authentication = AuthenticationFactory::getInstance($this->_params, $this);
139 139
             return;
Please login to merge, or discard this patch.