@@ -16,7 +16,7 @@ discard block |
||
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' => '', |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param string $json_string JSON string |
34 | 34 | * @param array $jwt_options array of options |
35 | 35 | */ |
36 | - public function __construct($json_string, $jwt_options=null) |
|
36 | + public function __construct($json_string, $jwt_options = null) |
|
37 | 37 | { |
38 | 38 | if (isset($jwt_options) && is_array($jwt_options)) |
39 | 39 | { |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | { |
75 | 75 | throw new Exception\JSON('json response contain an error message!'); |
76 | 76 | } |
77 | - if ( ! isset($this->json['status'])) |
|
77 | + if (!isset($this->json['status'])) |
|
78 | 78 | { |
79 | 79 | throw new Exception\JSON('invalid json response!'); |
80 | 80 | } |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | } |
85 | 85 | $this->status = $this->json['status']; |
86 | 86 | |
87 | - if ( ! isset($this->json['data']) || !is_array($this->json['data'])) |
|
87 | + if (!isset($this->json['data']) || !is_array($this->json['data'])) |
|
88 | 88 | { |
89 | 89 | throw new Exception\JSON('json does not contain the data field!'); |
90 | 90 | } |
91 | 91 | |
92 | 92 | if ($this->jwt['using'] === true) |
93 | 93 | { |
94 | - if ( ! isset($this->json['data']['token'])) |
|
94 | + if (!isset($this->json['data']['token'])) |
|
95 | 95 | { |
96 | 96 | throw new Exception\JSON('data does not contain the token field!'); |
97 | 97 | } |
@@ -112,8 +112,7 @@ discard block |
||
112 | 112 | { |
113 | 113 | $key = new Key(); |
114 | 114 | $public_key = $key->get($this->jwt['UAPAY_pubkey']); |
115 | - } |
|
116 | - catch (\Exception $e) |
|
115 | + } catch (\Exception $e) |
|
117 | 116 | { |
118 | 117 | throw new Exception\Runtime('The file with the public key was '.$e->getMessage().'!'); |
119 | 118 | } |
@@ -133,8 +132,7 @@ discard block |
||
133 | 132 | try |
134 | 133 | { |
135 | 134 | $decoded = (array) JWT::decode($token, $this->uapay_public_key(), array('RS512')); |
136 | - } |
|
137 | - catch (\Exception $e) |
|
135 | + } catch (\Exception $e) |
|
138 | 136 | { |
139 | 137 | Log::instance()->error($e->getMessage().PHP_EOL.$e->getTraceAsString()); |
140 | 138 | throw new Exception\JSON('unable to decode JWT token', $e); |
@@ -16,7 +16,7 @@ discard block |
||
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' => '', |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function __construct($options) |
37 | 37 | { |
38 | 38 | // api_url |
39 | - if ( ! isset($options['api_uri'])) |
|
39 | + if (!isset($options['api_uri'])) |
|
40 | 40 | { |
41 | 41 | throw new Exception\Data('parameter api_uri is not specified'); |
42 | 42 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param array $value |
58 | 58 | * @return array |
59 | 59 | */ |
60 | - public function data($value=null) |
|
60 | + public function data($value = null) |
|
61 | 61 | { |
62 | 62 | if ($value !== null) |
63 | 63 | { |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | * @param mixed $value |
74 | 74 | * @return string |
75 | 75 | */ |
76 | - protected function as_string($value=null) |
|
76 | + protected function as_string($value = null) |
|
77 | 77 | { |
78 | - return (is_scalar($value))?((is_bool($value))?(($value)?'true':'false'):"$value"):null; |
|
78 | + return (is_scalar($value)) ? ((is_bool($value)) ? (($value) ? 'true' : 'false') : "$value") : null; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @param mixed $value |
85 | 85 | * @return integer |
86 | 86 | */ |
87 | - protected function as_int($value=null) |
|
87 | + protected function as_int($value = null) |
|
88 | 88 | { |
89 | - return (is_int($value))?$value:null; |
|
89 | + return (is_int($value)) ? $value : null; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @param mixed $value |
96 | 96 | * @return array |
97 | 97 | */ |
98 | - protected function as_array($value=null) |
|
98 | + protected function as_array($value = null) |
|
99 | 99 | { |
100 | - return (is_array($value))?$value:null; |
|
100 | + return (is_array($value)) ? $value : null; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -140,7 +140,9 @@ discard block |
||
140 | 140 | $payload['iat'] = $this->get_param_iat(); |
141 | 141 | $ar['token'] = $this->token_encode($payload); |
142 | 142 | |
143 | - if (isset($ar['data'])) unset($ar['data']); |
|
143 | + if (isset($ar['data'])) { |
|
144 | + unset($ar['data']); |
|
145 | + } |
|
144 | 146 | } |
145 | 147 | $json = json_encode($ar, JSON_UNESCAPED_SLASHES); |
146 | 148 | |
@@ -162,8 +164,7 @@ discard block |
||
162 | 164 | { |
163 | 165 | $key = new Key(); |
164 | 166 | $private_key = $key->get($this->jwt['our_privkey']); |
165 | - } |
|
166 | - catch (\Exception $e) |
|
167 | + } catch (\Exception $e) |
|
167 | 168 | { |
168 | 169 | throw new Exception\Runtime('The file with the private key was '.$e->getMessage().'!'); |
169 | 170 | } |
@@ -185,8 +186,7 @@ discard block |
||
185 | 186 | try |
186 | 187 | { |
187 | 188 | $token = JWT::encode($payload, $this->own_private_key(), 'RS512'); |
188 | - } |
|
189 | - catch (\Exception $e) |
|
189 | + } catch (\Exception $e) |
|
190 | 190 | { |
191 | 191 | Log::instance()->error($e->getMessage().PHP_EOL.$e->getTraceAsString()); |
192 | 192 | throw new Exception\JSON('unable to create JWT token', $e); |
@@ -216,8 +216,7 @@ discard block |
||
216 | 216 | $body = $httpresponse->getBody()->getContents(); |
217 | 217 | Log::instance()->debug('got response:'.PHP_EOL.$body); |
218 | 218 | $response = new $this->response_class($body, $this->jwt); |
219 | - } |
|
220 | - catch (\GuzzleHttp\Exception\TransferException $e) |
|
219 | + } catch (\GuzzleHttp\Exception\TransferException $e) |
|
221 | 220 | { |
222 | 221 | Log::instance()->debug('request:'.PHP_EOL.\GuzzleHttp\Psr7\str($e->getRequest())); |
223 | 222 | if ($e->hasResponse()) { |
@@ -28,7 +28,7 @@ |
||
28 | 28 | */ |
29 | 29 | protected function check_exists($fname) |
30 | 30 | { |
31 | - if ( ! file_exists($fname)) |
|
31 | + if (!file_exists($fname)) |
|
32 | 32 | { |
33 | 33 | throw new Exception\Runtime('not exists'); |
34 | 34 | } |