Passed
Push — master ( 3b5652...fb3f32 )
by Dmitry
02:03
created
src/Request.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     /**
17 17
      *      @var Array
18 18
      */
19
-    protected $jwt=array(
19
+    protected $jwt = array(
20 20
         'using'         => false,
21 21
         'UAPAY_pubkey'  => '',
22 22
         'our_privkey'   => '',
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     public function __construct($options)
36 36
     {
37 37
         // api_url
38
-        if ( ! isset($options['api_uri']))
38
+        if (!isset($options['api_uri']))
39 39
         {
40 40
             throw new Exception\Data('parameter api_uri is not specified');
41 41
         }
@@ -43,21 +43,21 @@  discard block
 block discarded – undo
43 43
         if (isset($options['jwt']))
44 44
         {
45 45
             // using
46
-            if ( ! isset($options['jwt']['using']))
46
+            if (!isset($options['jwt']['using']))
47 47
             {
48 48
                 throw new Exception\Data('parameter jwt/using is not specified');
49 49
             }
50
-            if ( ! is_bool($options['jwt']['using']))
50
+            if (!is_bool($options['jwt']['using']))
51 51
             {
52 52
                 throw new Exception\Data('parameter jwt/using is incorrect');
53 53
             }
54 54
             // using
55
-            if ( ! isset($options['jwt']['UAPAY_pubkey']))
55
+            if (!isset($options['jwt']['UAPAY_pubkey']))
56 56
             {
57 57
                 throw new Exception\Data('parameter jwt/UAPAY_pubkey is not specified');
58 58
             }
59 59
             // using
60
-            if ( ! isset($options['jwt']['our_privkey']))
60
+            if (!isset($options['jwt']['our_privkey']))
61 61
             {
62 62
                 throw new Exception\Data('parameter jwt/our_privkey is not specified');
63 63
             }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      *      @param array $value
79 79
      *      @return array
80 80
      */
81
-    public function data($value=null)
81
+    public function data($value = null)
82 82
     {
83 83
         if ($value !== null)
84 84
         {
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
      *      @param mixed $value
95 95
      *      @return string
96 96
      */
97
-    protected function as_string($value=null)
97
+    protected function as_string($value = null)
98 98
     {
99
-        return (is_scalar($value))?((is_bool($value))?(($value)?'true':'false'):"$value"):null;
99
+        return (is_scalar($value)) ? ((is_bool($value)) ? (($value) ? 'true' : 'false') : "$value") : null;
100 100
     }
101 101
 
102 102
     /**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
      *      @param mixed $value
106 106
      *      @return integer
107 107
      */
108
-    protected function as_int($value=null)
108
+    protected function as_int($value = null)
109 109
     {
110
-        return (is_int($value))?$value:null;
110
+        return (is_int($value)) ? $value : null;
111 111
     }
112 112
 
113 113
     /**
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
      *      @param mixed $value
117 117
      *      @return array
118 118
      */
119
-    protected function as_array($value=null)
119
+    protected function as_array($value = null)
120 120
     {
121
-        return (is_array($value))?$value:null;
121
+        return (is_array($value)) ? $value : null;
122 122
     }
123 123
 
124 124
     /**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
             $payload['iat'] = $this->get_param_iat();
162 162
 
163 163
             // check private key file
164
-            if ( ! file_exists($this->jwt['our_privkey']))
164
+            if (!file_exists($this->jwt['our_privkey']))
165 165
             {
166 166
                 throw new Exception\Runtime('The file with the private key was not find!');
167 167
             }
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -182,14 +182,15 @@  discard block
 block discarded – undo
182 182
             try
183 183
             {
184 184
                 $token = JWT::encode($payload, $privateKey, 'RS512');
185
-            }
186
-            catch (\Exception $e)
185
+            } catch (\Exception $e)
187 186
             {
188 187
                 Log::instance()->error($e->getMessage().PHP_EOL.$e->getTraceAsString());
189 188
                 throw new Exception\JSON('unable to create JWT token', $e);
190 189
             }
191 190
 
192
-            if (isset($ar['data'])) unset($ar['data']);
191
+            if (isset($ar['data'])) {
192
+                unset($ar['data']);
193
+            }
193 194
 
194 195
             $ar['token'] = $token;
195 196
         }
@@ -216,8 +217,7 @@  discard block
 block discarded – undo
216 217
             $body = $httpresponse->getBody()->getContents();
217 218
             Log::instance()->debug('got response:'.PHP_EOL.$body);
218 219
             $response = new $this->response_class($body);
219
-        }
220
-        catch (\GuzzleHttp\Exception\TransferException $e)
220
+        } catch (\GuzzleHttp\Exception\TransferException $e)
221 221
         {
222 222
             Log::instance()->debug('request:'.PHP_EOL.\GuzzleHttp\Psr7\str($e->getRequest()));
223 223
             if ($e->hasResponse()) {
Please login to merge, or discard this patch.