@@ -64,16 +64,16 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if ($this->repository->has($consumerId)) { |
| 66 | 66 | $consumerData = $this->repository->get($consumerId); |
| 67 | - $consumerData[ 'id' ] = $consumerId; |
|
| 68 | - $consumerData[ 'currentCallTime' ] = $request->getTime(); |
|
| 69 | - $consumerData[ 'attempts' ] = 1; |
|
| 67 | + $consumerData['id'] = $consumerId; |
|
| 68 | + $consumerData['currentCallTime'] = $request->getTime(); |
|
| 69 | + $consumerData['attempts'] = 1; |
|
| 70 | 70 | |
| 71 | 71 | $this->consumer->merge($consumerData); |
| 72 | 72 | } else { |
| 73 | 73 | $consumerData = $this->consumer->getArrayCopy(); |
| 74 | - $consumerData[ 'id' ] = $consumerId; |
|
| 75 | - $consumerData[ 'lastCallTime' ] = $consumerData[ 'currentCallTime' ] = $request->getTime(); |
|
| 76 | - $consumerData[ 'attempts' ] = $consumerData[ 'attempts' ] + 1; |
|
| 74 | + $consumerData['id'] = $consumerId; |
|
| 75 | + $consumerData['lastCallTime'] = $consumerData['currentCallTime'] = $request->getTime(); |
|
| 76 | + $consumerData['attempts'] = $consumerData['attempts'] + 1; |
|
| 77 | 77 | |
| 78 | 78 | $this->repository->store($consumerId, $consumerData); |
| 79 | 79 | } |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | public function verify() |
| 83 | 83 | { |
| 84 | 84 | $currentTime = strtotime(date('r')); |
| 85 | - $timeCall = abs($this->consumer[ 'lastCallTime' ] - $currentTime); |
|
| 85 | + $timeCall = abs($this->consumer['lastCallTime'] - $currentTime); |
|
| 86 | 86 | |
| 87 | - $this->consumer[ 'lastCallTime' ] = $currentTime; |
|
| 87 | + $this->consumer['lastCallTime'] = $currentTime; |
|
| 88 | 88 | |
| 89 | - if ($timeCall > $this->rate[ 'span' ]) { |
|
| 89 | + if ($timeCall > $this->rate['span']) { |
|
| 90 | 90 | return false; |
| 91 | - } elseif ($this->consumer[ 'attempts' ] > $this->rate[ 'attempts' ]) { |
|
| 91 | + } elseif ($this->consumer['attempts'] > $this->rate['attempts']) { |
|
| 92 | 92 | return false; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | protected function getToken() |
| 62 | 62 | { |
| 63 | - if (isset($_SESSION[ 'captchaToken' ])) { |
|
| 64 | - return $_SESSION[ 'captchaToken' ]; |
|
| 63 | + if (isset($_SESSION['captchaToken'])) { |
|
| 64 | + return $_SESSION['captchaToken']; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return false; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function regenerate() |
| 80 | 80 | { |
| 81 | - $_SESSION[ 'captchaToken' ] = $this->token = strtoupper( |
|
| 81 | + $_SESSION['captchaToken'] = $this->token = strtoupper( |
|
| 82 | 82 | substr( |
| 83 | 83 | md5( |
| 84 | 84 | uniqid( |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function __construct() |
| 39 | 39 | { |
| 40 | - if (empty($_SESSION[ 'throttle' ])) { |
|
| 41 | - $_SESSION[ 'throttle' ] = []; |
|
| 40 | + if (empty($_SESSION['throttle'])) { |
|
| 41 | + $_SESSION['throttle'] = []; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function getIterator() |
| 56 | 56 | { |
| 57 | - return new \ArrayIterator($_SESSION[ 'throttle' ]); |
|
| 57 | + return new \ArrayIterator($_SESSION['throttle']); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // ------------------------------------------------------------------------ |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function offsetExists($offset) |
| 112 | 112 | { |
| 113 | - return isset($_SESSION[ 'throttle' ][ $offset ]); |
|
| 113 | + return isset($_SESSION['throttle'][$offset]); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // ------------------------------------------------------------------------ |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function &__get($offset) |
| 129 | 129 | { |
| 130 | - return $_SESSION[ 'throttle' ][ $offset ]; |
|
| 130 | + return $_SESSION['throttle'][$offset]; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // ------------------------------------------------------------------------ |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function offsetSet($offset, $value) |
| 185 | 185 | { |
| 186 | - $_SESSION[ 'throttle' ][ $offset ] = $value; |
|
| 186 | + $_SESSION['throttle'][$offset] = $value; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | // ------------------------------------------------------------------------ |
@@ -236,8 +236,8 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | public function offsetUnset($offset) |
| 238 | 238 | { |
| 239 | - if (isset($_SESSION[ 'throttle' ][ $offset ])) { |
|
| 240 | - unset($_SESSION[ 'throttle' ][ $offset ]); |
|
| 239 | + if (isset($_SESSION['throttle'][$offset])) { |
|
| 240 | + unset($_SESSION['throttle'][$offset]); |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
@@ -254,8 +254,8 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | public function merge(array $data) |
| 256 | 256 | { |
| 257 | - $oldData = $_SESSION[ 'throttle' ]; |
|
| 258 | - $_SESSION[ 'throttle' ] = array_merge($_SESSION[ 'throttle' ], $data); |
|
| 257 | + $oldData = $_SESSION['throttle']; |
|
| 258 | + $_SESSION['throttle'] = array_merge($_SESSION['throttle'], $data); |
|
| 259 | 259 | |
| 260 | 260 | return $oldData; |
| 261 | 261 | } |
@@ -273,8 +273,8 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | public function exchange(array $data) |
| 275 | 275 | { |
| 276 | - $oldData = $_SESSION[ 'throttle' ]; |
|
| 277 | - $_SESSION[ 'throttle' ] = $data; |
|
| 276 | + $oldData = $_SESSION['throttle']; |
|
| 277 | + $_SESSION['throttle'] = $data; |
|
| 278 | 278 | |
| 279 | 279 | return $oldData; |
| 280 | 280 | } |
@@ -290,9 +290,9 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | public function destroy() |
| 292 | 292 | { |
| 293 | - $storage = $_SESSION[ 'throttle' ]; |
|
| 293 | + $storage = $_SESSION['throttle']; |
|
| 294 | 294 | |
| 295 | - $_SESSION[ 'throttle' ] = []; |
|
| 295 | + $_SESSION['throttle'] = []; |
|
| 296 | 296 | |
| 297 | 297 | return $storage; |
| 298 | 298 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | public function count() |
| 311 | 311 | { |
| 312 | - return (int)count($_SESSION[ 'throttle' ]); |
|
| 312 | + return (int)count($_SESSION['throttle']); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // ------------------------------------------------------------------------ |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public function serialize() |
| 327 | 327 | { |
| 328 | - return serialize($_SESSION[ 'throttle' ]); |
|
| 328 | + return serialize($_SESSION['throttle']); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // ------------------------------------------------------------------------ |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | public function unserialize($serialized) |
| 345 | 345 | { |
| 346 | - $_SESSION[ 'throttle' ] = unserialize($serialized); |
|
| 346 | + $_SESSION['throttle'] = unserialize($serialized); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | // ------------------------------------------------------------------------ |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | public function jsonSerialize() |
| 362 | 362 | { |
| 363 | - return $_SESSION[ 'throttle' ]; |
|
| 363 | + return $_SESSION['throttle']; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | // ------------------------------------------------------------------------ |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | public function getArrayCopy() |
| 376 | 376 | { |
| 377 | - return $_SESSION[ 'throttle' ]; |
|
| 377 | + return $_SESSION['throttle']; |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | // ------------------------------------------------------------------------ |
@@ -432,6 +432,6 @@ discard block |
||
| 432 | 432 | */ |
| 433 | 433 | public function offsetGet($offset) |
| 434 | 434 | { |
| 435 | - return (isset($_SESSION[ 'throttle' ][ $offset ])) ? $_SESSION[ 'throttle' ][ $offset ] : false; |
|
| 435 | + return (isset($_SESSION['throttle'][$offset])) ? $_SESSION['throttle'][$offset] : false; |
|
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | 438 | \ No newline at end of file |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function getToken() |
| 56 | 56 | {
|
| 57 | - if (isset($_SESSION[ 'csrfToken' ])) {
|
|
| 58 | - return $_SESSION[ 'csrfToken' ]; |
|
| 57 | + if (isset($_SESSION['csrfToken'])) {
|
|
| 58 | + return $_SESSION['csrfToken']; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | return false; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function regenerate() |
| 74 | 74 | {
|
| 75 | - $_SESSION[ 'csrfToken' ] = $this->token = 'CSRF-' . bin2hex(random_bytes(32)); |
|
| 75 | + $_SESSION['csrfToken'] = $this->token = 'CSRF-' . bin2hex(random_bytes(32)); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // ------------------------------------------------------------------------ |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function addSource($key, $value) |
| 103 | 103 | { |
| 104 | - $this->sourceVars[ $key ] = $value; |
|
| 104 | + $this->sourceVars[$key] = $value; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // -------------------------------------------------------------------- |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | public function addRules(array $rules) |
| 115 | 115 | { |
| 116 | 116 | foreach ($rules as $rule) { |
| 117 | - $this->addRule($rule[ 'field' ], $rule[ 'label' ], $rule[ 'rules' ], $rule[ 'messages' ]); |
|
| 117 | + $this->addRule($rule['field'], $rule['label'], $rule['rules'], $rule['messages']); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function addRule($field, $label, $rules, $messages = []) |
| 132 | 132 | { |
| 133 | - $this->rules[ $field ] = [ |
|
| 133 | + $this->rules[$field] = [ |
|
| 134 | 134 | 'field' => $field, |
| 135 | 135 | 'label' => $label, |
| 136 | 136 | 'rules' => $rules, |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function setMessage($field, $message) |
| 168 | 168 | { |
| 169 | - $this->customErrors[ $field ] = $message; |
|
| 169 | + $this->customErrors[$field] = $message; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // ------------------------------------------------------------------------ |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | throw new OutOfRangeException('SECURITY_RULES_E_HEADER_OUTOFRANGEEXCEPTION', 1); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if (is_string($fieldParams[ 'rules' ])) { |
|
| 189 | + if (is_string($fieldParams['rules'])) { |
|
| 190 | 190 | /** |
| 191 | 191 | * Explode field rules by | as delimiter |
| 192 | 192 | */ |
| 193 | - $fieldRules = explode('|', $fieldParams[ 'rules' ]); |
|
| 193 | + $fieldRules = explode('|', $fieldParams['rules']); |
|
| 194 | 194 | |
| 195 | 195 | foreach ($fieldRules as $fieldRuleMethod) { |
| 196 | 196 | /* Get parameter from given data */ |
| 197 | - $fieldValue = $this->sourceVars[ $fieldName ]; |
|
| 197 | + $fieldValue = $this->sourceVars[$fieldName]; |
|
| 198 | 198 | if ( ! is_array($fieldValue)) { |
| 199 | 199 | $fieldValue = [$fieldValue]; |
| 200 | 200 | } |
@@ -210,16 +210,16 @@ discard block |
||
| 210 | 210 | $fieldRuleMethod = preg_replace("/\[.*\]/", '', $fieldRuleMethod); |
| 211 | 211 | |
| 212 | 212 | /* Explode rule parameter */ |
| 213 | - $fieldRuleParams = explode(',', preg_replace("/,[ ]+/", ',', $fieldRuleParams[ 1 ][ 0 ])); |
|
| 213 | + $fieldRuleParams = explode(',', preg_replace("/,[ ]+/", ',', $fieldRuleParams[1][0])); |
|
| 214 | 214 | |
| 215 | - if($fieldRuleMethod === 'match') { |
|
| 216 | - foreach($fieldRuleParams as $fieldRuleParamKey => $fieldRuleParamValue) { |
|
| 217 | - if(array_key_exists($fieldRuleParamValue, $this->sourceVars)) { |
|
| 218 | - $fieldRuleParams[ $fieldRuleParamKey ] = $this->sourceVars[ $fieldRuleParamValue ]; |
|
| 215 | + if ($fieldRuleMethod === 'match') { |
|
| 216 | + foreach ($fieldRuleParams as $fieldRuleParamKey => $fieldRuleParamValue) { |
|
| 217 | + if (array_key_exists($fieldRuleParamValue, $this->sourceVars)) { |
|
| 218 | + $fieldRuleParams[$fieldRuleParamKey] = $this->sourceVars[$fieldRuleParamValue]; |
|
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | - } elseif($fieldRuleMethod === 'listed') { |
|
| 222 | - $fieldRuleParams = [ $fieldRuleParams ]; |
|
| 221 | + } elseif ($fieldRuleMethod === 'listed') { |
|
| 222 | + $fieldRuleParams = [$fieldRuleParams]; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /* Merge method's param with field rule's params */ |
@@ -233,40 +233,40 @@ discard block |
||
| 233 | 233 | /* Throw exception if method not exists in validation class */ |
| 234 | 234 | if (method_exists($validationClass, $validationMethod)) { |
| 235 | 235 | $validationStatus = call_user_func_array([&$validationClass, $validationMethod], $fieldValue); |
| 236 | - } elseif(function_exists($fieldRuleMethod)) { |
|
| 236 | + } elseif (function_exists($fieldRuleMethod)) { |
|
| 237 | 237 | $validationStatus = call_user_func_array($fieldRuleMethod, $fieldValue); |
| 238 | - } elseif(is_callable($fieldRuleMethod)) { |
|
| 238 | + } elseif (is_callable($fieldRuleMethod)) { |
|
| 239 | 239 | $validationStatus = call_user_func_array($fieldRuleMethod, $fieldValue); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | if ($validationStatus === false) { |
| 243 | - if ( ! empty($fieldParams[ 'messages' ])) { |
|
| 244 | - $message = $fieldParams[ 'messages' ]; |
|
| 243 | + if ( ! empty($fieldParams['messages'])) { |
|
| 244 | + $message = $fieldParams['messages']; |
|
| 245 | 245 | |
| 246 | 246 | /* If $rule message is array, replace $message with specified message */ |
| 247 | - if (is_array($fieldParams[ 'messages' ])) { |
|
| 248 | - if (isset($fieldParams[ 'messages' ][ $fieldRuleMethod ])) { |
|
| 249 | - $message = $fieldParams[ 'messages' ][ $fieldRuleMethod ]; |
|
| 247 | + if (is_array($fieldParams['messages'])) { |
|
| 248 | + if (isset($fieldParams['messages'][$fieldRuleMethod])) { |
|
| 249 | + $message = $fieldParams['messages'][$fieldRuleMethod]; |
|
| 250 | 250 | } else { |
| 251 | - $message = $fieldParams[ 'messages' ][ $fieldName ]; |
|
| 251 | + $message = $fieldParams['messages'][$fieldName]; |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | } elseif (array_key_exists($fieldName, $this->customErrors)) { |
| 255 | - $message = $this->customErrors[ $fieldName ]; |
|
| 255 | + $message = $this->customErrors[$fieldName]; |
|
| 256 | 256 | } elseif (array_key_exists($fieldRuleMethod, $this->customErrors)) { |
| 257 | - $message = $this->customErrors[ $fieldRuleMethod ]; |
|
| 257 | + $message = $this->customErrors[$fieldRuleMethod]; |
|
| 258 | 258 | } else { |
| 259 | 259 | $message = 'RULE_' . strtoupper($fieldRuleMethod); |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /* Replace message placeholder, :attribute, :params */ |
| 263 | 263 | $message = str_replace(':attribute', |
| 264 | - (isset($fieldParams[ 'label' ]) ? $fieldParams[ 'label' ] : $fieldName), $message); |
|
| 265 | - if (isset($fieldRuleParams) AND ! empty($fieldRuleParams[ 0 ])) { |
|
| 264 | + (isset($fieldParams['label']) ? $fieldParams['label'] : $fieldName), $message); |
|
| 265 | + if (isset($fieldRuleParams) AND ! empty($fieldRuleParams[0])) { |
|
| 266 | 266 | $message = str_replace(':params', implode(',', $fieldRuleParams), $message); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - $this->setFieldError($fieldName, language($fieldParams[ 'label' ]), |
|
| 269 | + $this->setFieldError($fieldName, language($fieldParams['label']), |
|
| 270 | 270 | language($message, [$fieldValue])); |
| 271 | 271 | } |
| 272 | 272 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | protected function setFieldError($field, $label, $message) |
| 283 | 283 | { |
| 284 | - $this->errors[ $field ] = [ |
|
| 284 | + $this->errors[$field] = [ |
|
| 285 | 285 | 'label' => $label, |
| 286 | 286 | 'message' => $message, |
| 287 | 287 | ]; |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | $ul = new Unordered(); |
| 295 | 295 | |
| 296 | 296 | foreach ($this->getErrors() as $field => $errorParams) { |
| 297 | - $ul->createList($errorParams[ 'label' ] . ': ' . $errorParams[ 'message' ]); |
|
| 297 | + $ul->createList($errorParams['label'] . ': ' . $errorParams['message']); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | return $ul->render(); |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * @param $className |
| 17 | 17 | */ |
| 18 | 18 | spl_autoload_register( |
| 19 | - function ($className) {
|
|
| 19 | + function($className) {
|
|
| 20 | 20 | if (strpos($className, 'O2System\Security\\') === false) {
|
| 21 | 21 | return; |
| 22 | 22 | } |
@@ -141,15 +141,15 @@ discard block |
||
| 141 | 141 | ]; |
| 142 | 142 | |
| 143 | 143 | if (isset($httpUrl)) { |
| 144 | - $parameters[ 'oauth_signature' ] = $this->getSignature($signatureMethod, $httpUrl, $httpMethod, |
|
| 144 | + $parameters['oauth_signature'] = $this->getSignature($signatureMethod, $httpUrl, $httpMethod, |
|
| 145 | 145 | $parameters); |
| 146 | 146 | } else { |
| 147 | - $parameters[ 'oauth_signature' ] = $this->getSignature($signatureMethod, null, null, |
|
| 147 | + $parameters['oauth_signature'] = $this->getSignature($signatureMethod, null, null, |
|
| 148 | 148 | $parameters); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | if ( ! empty($this->callbackUrl)) { |
| 152 | - $parameters[ 'callback' ] = $this->callbackUrl; |
|
| 152 | + $parameters['callback'] = $this->callbackUrl; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | $parts = []; |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | ) { |
| 183 | 183 | if (isset($httpUrl)) { |
| 184 | 184 | $urlParts = parse_url($httpUrl); |
| 185 | - $scheme = $urlParts[ 'scheme' ]; |
|
| 186 | - $host = strtolower($urlParts[ 'host' ]); |
|
| 187 | - $path = $urlParts[ 'path' ]; |
|
| 185 | + $scheme = $urlParts['scheme']; |
|
| 186 | + $host = strtolower($urlParts['host']); |
|
| 187 | + $path = $urlParts['path']; |
|
| 188 | 188 | $httpUrl = "$scheme://$host$path"; |
| 189 | 189 | |
| 190 | 190 | $parts = [ |
@@ -90,51 +90,51 @@ discard block |
||
| 90 | 90 | $httpAuthorization = explode(' ', $httpAuthorization); |
| 91 | 91 | $httpAuthorization = array_map('trim', $httpAuthorization); |
| 92 | 92 | |
| 93 | - switch (strtoupper($httpAuthorization[ 0 ])) { |
|
| 93 | + switch (strtoupper($httpAuthorization[0])) { |
|
| 94 | 94 | default: |
| 95 | 95 | case 'OAUTH': |
| 96 | 96 | array_shift($httpAuthorization); |
| 97 | - $httpAuthorization = array_map(function ($string) { |
|
| 97 | + $httpAuthorization = array_map(function($string) { |
|
| 98 | 98 | $string = str_replace(['"', ','], '', $string); |
| 99 | 99 | $string = explode('=', $string); |
| 100 | 100 | |
| 101 | 101 | return [ |
| 102 | - 'key' => str_replace('oauth_', '', $string[ 0 ]), |
|
| 103 | - 'value' => $string[ 1 ], |
|
| 102 | + 'key' => str_replace('oauth_', '', $string[0]), |
|
| 103 | + 'value' => $string[1], |
|
| 104 | 104 | ]; |
| 105 | 105 | }, $httpAuthorization); |
| 106 | 106 | |
| 107 | 107 | $oauthParams = []; |
| 108 | 108 | foreach ($httpAuthorization as $param) { |
| 109 | - $oauthParams[ $param[ 'key' ] ] = $param[ 'value' ]; |
|
| 109 | + $oauthParams[$param['key']] = $param['value']; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - $this->oauth->signature_method = $oauthParams[ 'signature_method' ]; |
|
| 113 | - $this->oauth->nonce = $oauthParams[ 'nonce' ]; |
|
| 114 | - $this->oauth->timestamp = $oauthParams[ 'timestamp' ]; |
|
| 115 | - $this->oauth->consumer_key = $oauthParams[ 'consumer_key' ]; |
|
| 116 | - $this->oauth->version = $oauthParams[ 'version' ]; |
|
| 112 | + $this->oauth->signature_method = $oauthParams['signature_method']; |
|
| 113 | + $this->oauth->nonce = $oauthParams['nonce']; |
|
| 114 | + $this->oauth->timestamp = $oauthParams['timestamp']; |
|
| 115 | + $this->oauth->consumer_key = $oauthParams['consumer_key']; |
|
| 116 | + $this->oauth->version = $oauthParams['version']; |
|
| 117 | 117 | |
| 118 | - if (isset($oauthParams[ 'callback' ])) { |
|
| 119 | - $this->oauth->callback = urldecode($oauthParams[ 'callback' ]); |
|
| 118 | + if (isset($oauthParams['callback'])) { |
|
| 119 | + $this->oauth->callback = urldecode($oauthParams['callback']); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if (isset($oauthParams[ 'signature' ])) { |
|
| 123 | - $this->oauth->signature = $oauthParams[ 'signature' ]; |
|
| 122 | + if (isset($oauthParams['signature'])) { |
|
| 123 | + $this->oauth->signature = $oauthParams['signature']; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $this->oauth->callconsumerHandler(); |
| 127 | 127 | break; |
| 128 | 128 | case 'BASIC': |
| 129 | 129 | case 'BEARER': |
| 130 | - $this->oauth->bearer = $httpAuthorization[ 1 ]; |
|
| 130 | + $this->oauth->bearer = $httpAuthorization[1]; |
|
| 131 | 131 | $bearer = base64_decode($this->oauth->bearer); |
| 132 | 132 | $bearer = explode(':', $bearer); |
| 133 | 133 | $bearer = array_map('trim', $bearer); |
| 134 | 134 | |
| 135 | 135 | if (count($bearer) == 2) { |
| 136 | - $this->oauth->consumer_key = $bearer[ 0 ]; |
|
| 137 | - $this->oauth->consumer_secret = $bearer[ 1 ]; |
|
| 136 | + $this->oauth->consumer_key = $bearer[0]; |
|
| 137 | + $this->oauth->consumer_secret = $bearer[1]; |
|
| 138 | 138 | |
| 139 | 139 | $this->oauth->callconsumerHandler(); |
| 140 | 140 | } |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | $verifier = array_map('trim', $verifier); |
| 149 | 149 | |
| 150 | 150 | if (count($verifier) == 2) { |
| 151 | - $this->oauth->token = $verifier[ 0 ]; |
|
| 152 | - $this->oauth->token_secret = $verifier[ 1 ]; |
|
| 151 | + $this->oauth->token = $verifier[0]; |
|
| 152 | + $this->oauth->token_secret = $verifier[1]; |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
@@ -194,16 +194,16 @@ discard block |
||
| 194 | 194 | if ( ! empty($this->token)) { |
| 195 | 195 | if ($this->model->insertTokenNonce([ |
| 196 | 196 | 'id_consumer_token' => $this->token->id, |
| 197 | - 'nonce' => $token[ 'nonce' ] = Oauth::generateNonce(), |
|
| 198 | - 'timestamp' => $token[ 'timestamp' ] = date('Y-m-d H:m:s'), |
|
| 199 | - 'expires' => $token[ 'expires' ] = time() + 3600, |
|
| 197 | + 'nonce' => $token['nonce'] = Oauth::generateNonce(), |
|
| 198 | + 'timestamp' => $token['timestamp'] = date('Y-m-d H:m:s'), |
|
| 199 | + 'expires' => $token['expires'] = time() + 3600, |
|
| 200 | 200 | ])) { |
| 201 | 201 | return new Datastructures\Token([ |
| 202 | 202 | 'key' => $this->token->key, |
| 203 | 203 | 'secret' => $this->token->secret, |
| 204 | - 'nonce' => $token[ 'nonce' ], |
|
| 205 | - 'timestamp' => $token[ 'timestamp' ], |
|
| 206 | - 'expires' => $token[ 'expires' ], |
|
| 204 | + 'nonce' => $token['nonce'], |
|
| 205 | + 'timestamp' => $token['timestamp'], |
|
| 206 | + 'expires' => $token['expires'], |
|
| 207 | 207 | 'verifier' => (new Token($this->token->key, $this->token->secret))->getVerifier(), |
| 208 | 208 | ]); |
| 209 | 209 | } |
@@ -211,17 +211,17 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | $token = $this->generateToken('ACCESS'); |
| 213 | 213 | $token = new Datastructures\Token([ |
| 214 | - 'id' => $token[ 'id' ], |
|
| 215 | - 'key' => $token[ 'key' ], |
|
| 216 | - 'secret' => $token[ 'secret' ], |
|
| 217 | - 'verifier' => (new Token($token[ 'key' ], $token[ 'secret' ]))->getVerifier(), |
|
| 214 | + 'id' => $token['id'], |
|
| 215 | + 'key' => $token['key'], |
|
| 216 | + 'secret' => $token['secret'], |
|
| 217 | + 'verifier' => (new Token($token['key'], $token['secret']))->getVerifier(), |
|
| 218 | 218 | ]); |
| 219 | 219 | |
| 220 | 220 | if ($this->model->insertTokenNonce([ |
| 221 | - 'id_consumer_token' => $token[ 'id' ], |
|
| 222 | - 'nonce' => $token[ 'nonce' ] = Oauth::generateNonce(), |
|
| 223 | - 'timestamp' => $token[ 'timestamp' ] = date('Y-m-d H:m:s'), |
|
| 224 | - 'expires' => $token[ 'expires' ] = time() + 3600, |
|
| 221 | + 'id_consumer_token' => $token['id'], |
|
| 222 | + 'nonce' => $token['nonce'] = Oauth::generateNonce(), |
|
| 223 | + 'timestamp' => $token['timestamp'] = date('Y-m-d H:m:s'), |
|
| 224 | + 'expires' => $token['expires'] = time() + 3600, |
|
| 225 | 225 | ])) { |
| 226 | 226 | return $token; |
| 227 | 227 | } |
@@ -284,15 +284,15 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | if ($this->model->insertToken([ |
| 286 | 286 | 'id_consumer' => $this->consumer->id, |
| 287 | - 'key' => $token[ 'key' ], |
|
| 288 | - 'secret' => $token[ 'secret' ], |
|
| 287 | + 'key' => $token['key'], |
|
| 288 | + 'secret' => $token['secret'], |
|
| 289 | 289 | 'type' => $type, |
| 290 | 290 | 'callback' => $callback, |
| 291 | 291 | ])) { |
| 292 | - $token[ 'id' ] = $this->model->db->getLastInsertId(); |
|
| 292 | + $token['id'] = $this->model->db->getLastInsertId(); |
|
| 293 | 293 | |
| 294 | 294 | if ($this->model->insertTokenNonce([ |
| 295 | - 'id_consumer_token' => $token[ 'id' ], |
|
| 295 | + 'id_consumer_token' => $token['id'], |
|
| 296 | 296 | 'nonce' => $nonce, |
| 297 | 297 | 'timestamp' => date('Y-m-d H:m:s'), |
| 298 | 298 | 'expires' => time() + 3600, |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | { |
| 26 | 26 | public function __construct(array $role) |
| 27 | 27 | { |
| 28 | - foreach($role as $key => $value) { |
|
| 28 | + foreach ($role as $key => $value) { |
|
| 29 | 29 | $this->store($key, $value); |
| 30 | 30 | } |
| 31 | 31 | } |