@@ -42,7 +42,7 @@ |
||
42 | 42 | { |
43 | 43 | throw new FormatException('invalid json response!'); |
44 | 44 | } |
45 | - $this->error_code = (isset($this->json['error']['code']))?$this->json['error']['code']:'undefined'; |
|
45 | + $this->error_code = (isset($this->json['error']['code'])) ? $this->json['error']['code'] : 'undefined'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -37,7 +37,7 @@ |
||
37 | 37 | * @param string $value |
38 | 38 | * @return string |
39 | 39 | */ |
40 | - public function sessionId($value=null) |
|
40 | + public function sessionId($value = null) |
|
41 | 41 | { |
42 | 42 | if ($value !== null) |
43 | 43 | { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string $value |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - public function sessionId($value=null) |
|
45 | + public function sessionId($value = null) |
|
46 | 46 | { |
47 | 47 | if ($value !== null) |
48 | 48 | { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param string $value |
59 | 59 | * @return string |
60 | 60 | */ |
61 | - public function id($value=null) |
|
61 | + public function id($value = null) |
|
62 | 62 | { |
63 | 63 | if ($value !== null) |
64 | 64 | { |
@@ -37,7 +37,7 @@ |
||
37 | 37 | * @param string $value |
38 | 38 | * @return string |
39 | 39 | */ |
40 | - public function id($value=null) |
|
40 | + public function id($value = null) |
|
41 | 41 | { |
42 | 42 | if ($value !== null) |
43 | 43 | { |
@@ -11,9 +11,9 @@ |
||
11 | 11 | * @param string $message |
12 | 12 | * @param Throwable $previous |
13 | 13 | */ |
14 | - public function __construct($message, \Exception $previous=null, $tracelog=false) |
|
14 | + public function __construct($message, \Exception $previous = null, $tracelog = false) |
|
15 | 15 | { |
16 | - Log::instance()->error($message.(($tracelog)?PHP_EOL.$this->getTraceAsString():null)); |
|
16 | + Log::instance()->error($message.(($tracelog) ?PHP_EOL.$this->getTraceAsString() : null)); |
|
17 | 17 | $code = 0; |
18 | 18 | parent::__construct($message, $code, $previous); |
19 | 19 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * @param string $value |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - public function clientId($value=null) |
|
45 | + public function clientId($value = null) |
|
46 | 46 | { |
47 | 47 | if ($value !== null) |
48 | 48 | { |
@@ -80,7 +80,7 @@ |
||
80 | 80 | */ |
81 | 81 | protected function get_http_raw_post_data() |
82 | 82 | { |
83 | - Log::instance()->add('callback request from ' . $_SERVER['REMOTE_ADDR']); |
|
83 | + Log::instance()->add('callback request from '.$_SERVER['REMOTE_ADDR']); |
|
84 | 84 | |
85 | 85 | $raw_request = file_get_contents('php://input'); |
86 | 86 |
@@ -37,7 +37,7 @@ |
||
37 | 37 | * @param string $value |
38 | 38 | * @return string |
39 | 39 | */ |
40 | - public function sessionId($value=null) |
|
40 | + public function sessionId($value = null) |
|
41 | 41 | { |
42 | 42 | if ($value !== null) |
43 | 43 | { |
@@ -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' => '', |
@@ -35,7 +35,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -182,14 +182,15 @@ discard block |
||
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 |
||
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()) { |