Passed
Push — master ( 27c581...94a645 )
by Rodrigo
02:00
created
src/OneDocApi.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,8 @@
 block discarded – undo
55 55
      */
56 56
     public $instructs = [
57 57
         'method' => '',
58
-	    'client_auth' => self::XXX,
59
-	    'token' => self::XXX,
58
+        'client_auth' => self::XXX,
59
+        'token' => self::XXX,
60 60
         'secret' => self::XXX,
61 61
     ];
62 62
 
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
      * 
108 108
      * @return void
109 109
      */
110
-    public function __construct( $config = [] )
110
+    public function __construct($config = [])
111 111
     {
112 112
         /** 
113 113
          * @see componet dynamikaweb\OneDocAuth
114 114
          */
115
-        Yii::$app->set( 'OneDocAuth', new OneDocAuth );
116
-        parent::__construct( $config );
115
+        Yii::$app->set('OneDocAuth', new OneDocAuth);
116
+        parent::__construct($config);
117 117
     }
118 118
 
119 119
     /**
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
      * 
124 124
      * @return void
125 125
      */
126
-    public function init ( )
126
+    public function init( )
127 127
     {        
128 128
         // Define uma URL padrão para quando não foi escolhida
129
-        if ( !$this->url_request ) {
129
+        if (!$this->url_request) {
130 130
             $url = self::URLS;
131 131
             $this->url_request = current($url);
132 132
         }      
@@ -142,21 +142,21 @@  discard block
 block discarded – undo
142 142
      *
143 143
      * @return array $this->instructs
144 144
      */
145
-    public function find( $options )
145
+    public function find($options)
146 146
     {
147
-        foreach ($options as $option => $value){
147
+        foreach ($options as $option => $value) {
148 148
             // se o parametro for o metodo, colocar prefixo emission
149
-            if($option == 'method'){
149
+            if ($option == 'method') {
150 150
                 $this->instructs['method'] = 'emission'.ucfirst($value);
151 151
                 continue; 
152 152
             }
153 153
             // parametros que estão em emissão
154
-            if( isset($this->rules['emissao'][$option]) ){
154
+            if (isset($this->rules['emissao'][$option])) {
155 155
                 $this->instructs['emissao'][$this->rules['emissao'][$option]] = $value;
156 156
                 continue;
157 157
             }
158 158
             // parametros aceitos fora de emissão
159
-            if( isset($this->rules[$option]) ){
159
+            if (isset($this->rules[$option])) {
160 160
                 $this->instructs[$this->rules[$option]] = $value;
161 161
                 continue;
162 162
             }
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function getRun()
176 176
     {
177
-        $ch= curl_init();
177
+        $ch = curl_init();
178 178
         curl_setopt($ch, CURLOPT_URL, $this->url_request);
179 179
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
180 180
         curl_setopt($ch, CURLOPT_POST, 1);
181
-        curl_setopt($ch, CURLOPT_POSTFIELDS, "data=". base64_encode($this->getRequest(true)));
181
+        curl_setopt($ch, CURLOPT_POSTFIELDS, "data=".base64_encode($this->getRequest(true)));
182 182
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
183 183
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
184
-        $this->data = json_decode(curl_exec ($ch));
184
+        $this->data = json_decode(curl_exec($ch));
185 185
         curl_close($ch);
186 186
         return $this;
187 187
     }
@@ -193,17 +193,17 @@  discard block
 block discarded – undo
193 193
      *
194 194
      * @return string-json a requisão que sera feita para api 1doc
195 195
      */
196
-    public function getRequest( $real = false )
196
+    public function getRequest($real = false)
197 197
     {
198 198
         $json = $this->instructs;
199 199
 
200 200
         // se for uma requisição real, substiuir autenticação ficticia pela verdadeira
201
-        if( $real ){
201
+        if ($real) {
202 202
             $auth = Yii::$app->OneDocAuth; // objeto de autenticação
203
-            $json = \yii\helpers\ArrayHelper::merge( $json, $auth() ); 
203
+            $json = \yii\helpers\ArrayHelper::merge($json, $auth()); 
204 204
         }
205 205
         
206
-        return \yii\helpers\Json::encode( $json, false );
206
+        return \yii\helpers\Json::encode($json, false);
207 207
     }
208 208
 
209 209
     /**
@@ -213,19 +213,19 @@  discard block
 block discarded – undo
213 213
      * @param mixed $value
214 214
      * 
215 215
      */
216
-    public function __set( $name, $value )
216
+    public function __set($name, $value)
217 217
     {
218 218
         switch ($name)
219 219
         {
220 220
             case 'client_auth': case 'token': case 'secret':
221 221
                 Yii::$app->OneDocAuth->$name = $value;
222
-            return ;
222
+            return;
223 223
             case 'url': 
224 224
                 $urls = self::URLS;
225
-                $this->url_request = !isset($urls[$value]) ? $value:$urls[$value];
226
-            return ;
225
+                $this->url_request = !isset($urls[$value]) ? $value : $urls[$value];
226
+            return;
227 227
         }
228 228
         
229
-        parent::__set( $name, $value );
229
+        parent::__set($name, $value);
230 230
     }
231 231
 }
Please login to merge, or discard this patch.
src/OneDocAuth.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
             'secret' => $this->secret
17 17
         ];
18 18
 
19
-        if( ($index = array_search( null, $auth )) !== false ){
19
+        if (($index = array_search(null, $auth)) !== false) {
20 20
             throw new OneDocException("Autenticação Incompleta!\nNão foi encontrado: ".$index);
21 21
         }
22 22
     
Please login to merge, or discard this patch.