@@ -349,8 +349,7 @@ discard block |
||
| 349 | 349 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 350 | 350 | $this->generatorList[] = $generator; |
| 351 | 351 | } |
| 352 | - } |
|
| 353 | - else {
|
|
| 352 | + } else {
|
|
| 354 | 353 | |
| 355 | 354 | if($this->checkProperties('auto_generators_dont_overwrite')
|
| 356 | 355 | && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){
|
@@ -603,8 +602,7 @@ discard block |
||
| 603 | 602 | $keyMethod = $this->{$method}();
|
| 604 | 603 | $this->inputs[$key] = $keyMethod; |
| 605 | 604 | } |
| 606 | - } |
|
| 607 | - else{
|
|
| 605 | + } else{
|
|
| 608 | 606 | if(isset($this->inputs[$key])){
|
| 609 | 607 | $keyMethod = $this->{$method}();
|
| 610 | 608 | $this->inputs[$key] = $keyMethod; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @throws ReflectionExceptionAlias |
| 72 | 72 | */ |
| 73 | - public function __construct($clientData=null) |
|
| 73 | + public function __construct($clientData = null) |
|
| 74 | 74 | {
|
| 75 | 75 | //reflection process |
| 76 | 76 | $this->reflection = app()['reflection']($this); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $this->setClientName(); |
| 80 | 80 | |
| 81 | 81 | //get http method via request http manager class |
| 82 | - $this->requestHttp = app()->resolve(ClientHttpManager::class,['client'=>$this]); |
|
| 82 | + $this->requestHttp = app()->resolve(ClientHttpManager::class, ['client'=>$this]); |
|
| 83 | 83 | |
| 84 | 84 | //get request client data |
| 85 | 85 | $this->clientData = ($clientData===null) ? $this->requestHttp->resolve() : $clientData; |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | private function autoValidate($validate) |
| 97 | 97 | {
|
| 98 | 98 | //we get the values to auto-validate. |
| 99 | - foreach ($this->{$validate} as $object=>$datas){
|
|
| 99 | + foreach ($this->{$validate} as $object=>$datas) {
|
|
| 100 | 100 | |
| 101 | - if(false===Utils::isNamespaceExists($object)){
|
|
| 101 | + if (false===Utils::isNamespaceExists($object)) {
|
|
| 102 | 102 | return; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -108,30 +108,30 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | // we get the index values, |
| 110 | 110 | // which are called methods of the auto-validate value that represents the class. |
| 111 | - foreach ($datas as $dataKey=>$data){
|
|
| 111 | + foreach ($datas as $dataKey=>$data) {
|
|
| 112 | 112 | |
| 113 | 113 | // if the methods of the auto-validate class resolved by the container resolve method apply, |
| 114 | 114 | // the process of auto-validate automatic implementation will be completed. |
| 115 | - if(method_exists($getObjectInstance,$dataKey) && is_array($data)){
|
|
| 116 | - foreach ($data as $dataItem){
|
|
| 117 | - if(isset($this->origin[$dataItem])){
|
|
| 118 | - $getObjectInstance->{$dataKey}($this->origin[$dataItem],$this,$dataItem);
|
|
| 115 | + if (method_exists($getObjectInstance, $dataKey) && is_array($data)) {
|
|
| 116 | + foreach ($data as $dataItem) {
|
|
| 117 | + if (isset($this->origin[$dataItem])) {
|
|
| 118 | + $getObjectInstance->{$dataKey}($this->origin[$dataItem], $this, $dataItem);
|
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if(method_exists($this,$afterMethod = 'after'.ucfirst($dataKey))){
|
|
| 122 | - $this->{$afterMethod}($this,$dataItem);
|
|
| 121 | + if (method_exists($this, $afterMethod = 'after'.ucfirst($dataKey))) {
|
|
| 122 | + $this->{$afterMethod}($this, $dataItem);
|
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // if the methods of the auto-validate class resolved by the container resolve method apply, |
| 128 | 128 | // the process of auto-validate automatic implementation will be completed. |
| 129 | - if(is_numeric($dataKey) && method_exists($getObjectInstance,$data) && isset($this->origin[$data])){
|
|
| 130 | - if(!is_array($this->origin[$data])){
|
|
| 129 | + if (is_numeric($dataKey) && method_exists($getObjectInstance, $data) && isset($this->origin[$data])) {
|
|
| 130 | + if (!is_array($this->origin[$data])) {
|
|
| 131 | 131 | $this->origin[$data] = array($this->origin[$data]); |
| 132 | 132 | } |
| 133 | - foreach ($this->origin[$data] as $originData){
|
|
| 134 | - $getObjectInstance->{$data}($originData,$this,$data);
|
|
| 133 | + foreach ($this->origin[$data] as $originData) {
|
|
| 134 | + $getObjectInstance->{$data}($originData, $this, $data);
|
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -146,39 +146,39 @@ discard block |
||
| 146 | 146 | private function capsule() |
| 147 | 147 | {
|
| 148 | 148 | //a process can be added to the capsule array using the method. |
| 149 | - if(method_exists($this,'capsuleMethod')){
|
|
| 150 | - $this->capsule = array_merge($this->capsule,$this->capsuleMethod()); |
|
| 149 | + if (method_exists($this, 'capsuleMethod')) {
|
|
| 150 | + $this->capsule = array_merge($this->capsule, $this->capsuleMethod()); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // expected method is executed. |
| 154 | 154 | // this method is a must for http method values to be found in this property. |
| 155 | - if($this->checkProperties('capsule')){
|
|
| 155 | + if ($this->checkProperties('capsule')) {
|
|
| 156 | 156 | |
| 157 | - if(property_exists($this,'auto_capsule') && is_array($this->auto_capsule)){
|
|
| 158 | - $this->capsule = array_merge($this->capsule,$this->auto_capsule); |
|
| 157 | + if (property_exists($this, 'auto_capsule') && is_array($this->auto_capsule)) {
|
|
| 158 | + $this->capsule = array_merge($this->capsule, $this->auto_capsule); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if($this->checkProperties('groups')){
|
|
| 162 | - $this->capsule = array_merge($this->capsule,$this->groups); |
|
| 161 | + if ($this->checkProperties('groups')) {
|
|
| 162 | + $this->capsule = array_merge($this->capsule, $this->groups); |
|
| 163 | 163 | |
| 164 | 164 | foreach ($this->capsule as $item) {
|
| 165 | - $groupProcess = $this->groupsProcess($item,true); |
|
| 166 | - if(is_array($groupProcess)){
|
|
| 165 | + $groupProcess = $this->groupsProcess($item, true); |
|
| 166 | + if (is_array($groupProcess)) {
|
|
| 167 | 167 | $defaultInputs = $this->inputs; |
| 168 | - $this->inputs = array_merge($this->inputs,$groupProcess); |
|
| 168 | + $this->inputs = array_merge($this->inputs, $groupProcess); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - foreach($this->inputs as $input=>$value){
|
|
| 173 | + foreach ($this->inputs as $input=>$value) {
|
|
| 174 | 174 | |
| 175 | - if($this->checkProperties('capsule') && !in_array($input,$this->capsule)){
|
|
| 176 | - exception('clientCapsule',['key'=>$input])
|
|
| 175 | + if ($this->checkProperties('capsule') && !in_array($input, $this->capsule)) {
|
|
| 176 | + exception('clientCapsule', ['key'=>$input])
|
|
| 177 | 177 | ->overflow('The '.$input.' value cannot be sent.');
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if(isset($defaultInputs)){
|
|
| 181 | + if (isset($defaultInputs)) {
|
|
| 182 | 182 | $this->inputs = $defaultInputs; |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -196,15 +196,15 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | // Determines which HTTP method |
| 198 | 198 | // the request object will be exposed to. |
| 199 | - if($this->checkProperties('http')){
|
|
| 199 | + if ($this->checkProperties('http')) {
|
|
| 200 | 200 | |
| 201 | 201 | // if the current http method does not exist |
| 202 | 202 | // in the http object, the exception will be thrown. |
| 203 | - if(!in_array($method,$this->http)){
|
|
| 203 | + if (!in_array($method, $this->http)) {
|
|
| 204 | 204 | |
| 205 | 205 | //exception batMethodCall |
| 206 | 206 | exception()->badMethodCall( |
| 207 | - 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] ');
|
|
| 207 | + 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] ');
|
|
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | {
|
| 220 | 220 | // from the properties of the object properties to |
| 221 | 221 | // the existing variables, control the array and at least one element. |
| 222 | - return (property_exists($this,$properties) |
|
| 222 | + return (property_exists($this, $properties) |
|
| 223 | 223 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false;
|
| 224 | 224 | } |
| 225 | 225 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | {
|
| 233 | 233 | // we are saving the expected values for the request in container. |
| 234 | 234 | // this record can be returned in exception information. |
| 235 | - app()->register('requestExpected',$this->expected);
|
|
| 235 | + app()->register('requestExpected', $this->expected);
|
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -244,15 +244,15 @@ discard block |
||
| 244 | 244 | public function except($except) |
| 245 | 245 | {
|
| 246 | 246 | // the except parameter is a callable value. |
| 247 | - if(is_callable($except)){
|
|
| 248 | - $call = call_user_func_array($except,[$this]); |
|
| 247 | + if (is_callable($except)) {
|
|
| 248 | + $call = call_user_func_array($except, [$this]); |
|
| 249 | 249 | $except = $call; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | // except with the except exceptions property |
| 253 | 253 | // and then assigning them to the inputs property. |
| 254 | - $this->except = array_merge($this->except,$except); |
|
| 255 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
| 254 | + $this->except = array_merge($this->except, $except); |
|
| 255 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
| 256 | 256 | |
| 257 | 257 | return $this; |
| 258 | 258 | } |
@@ -266,32 +266,32 @@ discard block |
||
| 266 | 266 | {
|
| 267 | 267 | // expected method is executed. |
| 268 | 268 | // this method is a must for http method values to be found in this property. |
| 269 | - if($this->checkProperties('expected')){
|
|
| 269 | + if ($this->checkProperties('expected')) {
|
|
| 270 | 270 | |
| 271 | 271 | // if the expected values are not found in the inputs array, |
| 272 | 272 | // the exception will be thrown. |
| 273 | - foreach ($this->expected as $expected){
|
|
| 273 | + foreach ($this->expected as $expected) {
|
|
| 274 | 274 | |
| 275 | 275 | $expectedValues = []; |
| 276 | 276 | |
| 277 | 277 | // mandatory expected data for each key can be separated by | operator. |
| 278 | 278 | // this is evaluated as "or". |
| 279 | - foreach($expectedData = explode("|",$expected) as $inputs){
|
|
| 279 | + foreach ($expectedData = explode("|", $expected) as $inputs) {
|
|
| 280 | 280 | |
| 281 | 281 | // we should do key control for group format. |
| 282 | 282 | // this process will allow us to perform key control for 2D array correctly. |
| 283 | 283 | $this->groupsProcess($inputs); |
| 284 | 284 | |
| 285 | - if(!isset($this->inputs[$inputs])){
|
|
| 285 | + if (!isset($this->inputs[$inputs])) {
|
|
| 286 | 286 | $expectedValues[$inputs] = $inputs; |
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | // if the expectedData and expectedValues |
| 291 | 291 | // array are numerically equal to the expected key, the exception is thrown. |
| 292 | - if(count($expectedData)===count($expectedValues)){
|
|
| 293 | - exception('clientExpected',['key'=>$expected])
|
|
| 294 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object');
|
|
| 292 | + if (count($expectedData)===count($expectedValues)) {
|
|
| 293 | + exception('clientExpected', ['key'=>$expected])
|
|
| 294 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object');
|
|
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | 297 | } |
@@ -306,17 +306,17 @@ discard block |
||
| 306 | 306 | {
|
| 307 | 307 | // check the presence of the generator object |
| 308 | 308 | // and operate the generator over this object. |
| 309 | - if($this->checkProperties('auto_generators')){
|
|
| 309 | + if ($this->checkProperties('auto_generators')) {
|
|
| 310 | 310 | $generators = $this->getAutoGenerators(); |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | // check the presence of the generator object |
| 314 | 314 | // and operate the generator over this object. |
| 315 | - if($this->checkProperties('generators')){
|
|
| 316 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
| 315 | + if ($this->checkProperties('generators')) {
|
|
| 316 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - if(isset($generators)){
|
|
| 319 | + if (isset($generators)) {
|
|
| 320 | 320 | $this->generatorMethod($generators); |
| 321 | 321 | } |
| 322 | 322 | } |
@@ -331,21 +331,21 @@ discard block |
||
| 331 | 331 | private function generatorMethod($generators) |
| 332 | 332 | {
|
| 333 | 333 | //generator array object |
| 334 | - foreach ($generators as $generator){
|
|
| 334 | + foreach ($generators as $generator) {
|
|
| 335 | 335 | |
| 336 | 336 | //generator method name |
| 337 | 337 | $generatorMethodName = $generator.'Generator'; |
| 338 | 338 | |
| 339 | 339 | // if the generator method is present, |
| 340 | 340 | // the fake value is assigned. |
| 341 | - if(method_exists($this,$generatorMethodName)){
|
|
| 341 | + if (method_exists($this, $generatorMethodName)) {
|
|
| 342 | 342 | |
| 343 | 343 | //fake registration |
| 344 | - if(!isset($this->inputs[$generator])){
|
|
| 344 | + if (!isset($this->inputs[$generator])) {
|
|
| 345 | 345 | |
| 346 | 346 | $generatorMethodNameResult = $this->{$generatorMethodName}();
|
| 347 | 347 | |
| 348 | - if(!is_null($generatorMethodNameResult)){
|
|
| 348 | + if (!is_null($generatorMethodNameResult)) {
|
|
| 349 | 349 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 350 | 350 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 351 | 351 | $this->generatorList[] = $generator; |
@@ -353,15 +353,15 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | else {
|
| 355 | 355 | |
| 356 | - if($this->checkProperties('auto_generators_dont_overwrite')
|
|
| 357 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){
|
|
| 356 | + if ($this->checkProperties('auto_generators_dont_overwrite')
|
|
| 357 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) {
|
|
| 358 | 358 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 359 | 359 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 360 | 360 | $this->generatorList[] = $generator; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - if($this->checkProperties('generators_dont_overwrite')
|
|
| 364 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){
|
|
| 363 | + if ($this->checkProperties('generators_dont_overwrite')
|
|
| 364 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) {
|
|
| 365 | 365 | $this->{$generator} = $this->{$generatorMethodName}();
|
| 366 | 366 | $this->inputs[$generator] = $this->{$generatorMethodName}();
|
| 367 | 367 | $this->generatorList[] = $generator; |
@@ -392,28 +392,28 @@ discard block |
||
| 392 | 392 | * @param null $callback |
| 393 | 393 | * @return mixed|void |
| 394 | 394 | */ |
| 395 | - public function groupsProcess($key=null,$callback=null) |
|
| 395 | + public function groupsProcess($key = null, $callback = null) |
|
| 396 | 396 | {
|
| 397 | - if(property_exists($this,'groups') && is_array($this->groups)){
|
|
| 397 | + if (property_exists($this, 'groups') && is_array($this->groups)) {
|
|
| 398 | 398 | |
| 399 | 399 | $clientObjects = $this->getClientObjects(); |
| 400 | 400 | |
| 401 | - foreach ($this->groups as $group){
|
|
| 401 | + foreach ($this->groups as $group) {
|
|
| 402 | 402 | |
| 403 | - if(true === $callback){
|
|
| 404 | - if(isset($clientObjects['origin'][$key])){
|
|
| 403 | + if (true===$callback) {
|
|
| 404 | + if (isset($clientObjects['origin'][$key])) {
|
|
| 405 | 405 | return $clientObjects['origin'][$key]; |
| 406 | 406 | } |
| 407 | 407 | return []; |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - if(isset($clientObjects['origin'][$group][$key])){
|
|
| 410 | + if (isset($clientObjects['origin'][$group][$key])) {
|
|
| 411 | 411 | |
| 412 | 412 | $this->{$key} = $clientObjects['origin'][$group][$key];
|
| 413 | 413 | $this->inputs[$key] = $this->{$key};
|
| 414 | 414 | |
| 415 | - if(is_callable($callback)){
|
|
| 416 | - call_user_func_array($callback,[$key]); |
|
| 415 | + if (is_callable($callback)) {
|
|
| 416 | + call_user_func_array($callback, [$key]); |
|
| 417 | 417 | } |
| 418 | 418 | } |
| 419 | 419 | } |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | //that coming with the post. |
| 439 | 439 | $this->initClient(); |
| 440 | 440 | |
| 441 | - if(method_exists($this,'eventBefore')){
|
|
| 441 | + if (method_exists($this, 'eventBefore')) {
|
|
| 442 | 442 | $this->eventBefore(); |
| 443 | 443 | } |
| 444 | 444 | |
@@ -474,11 +474,11 @@ discard block |
||
| 474 | 474 | // are subtracted from all input values. |
| 475 | 475 | $this->requestExcept(); |
| 476 | 476 | |
| 477 | - if(app()->has('clientRequestInputs')){
|
|
| 477 | + if (app()->has('clientRequestInputs')) {
|
|
| 478 | 478 | app()->terminate('clientRequestInputs');
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - app()->register('clientRequestInputs',$this->inputs);
|
|
| 481 | + app()->register('clientRequestInputs', $this->inputs);
|
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | /** |
@@ -489,18 +489,18 @@ discard block |
||
| 489 | 489 | private function unity() |
| 490 | 490 | {
|
| 491 | 491 | // unity method is executed. |
| 492 | - if($this->checkProperties('unity')){
|
|
| 492 | + if ($this->checkProperties('unity')) {
|
|
| 493 | 493 | |
| 494 | 494 | $list = []; |
| 495 | 495 | |
| 496 | - foreach ($this->unity as $unity){
|
|
| 497 | - if(isset($this->inputs[$unity])){
|
|
| 496 | + foreach ($this->unity as $unity) {
|
|
| 497 | + if (isset($this->inputs[$unity])) {
|
|
| 498 | 498 | $list[] = $unity; |
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - if(count($list)>1){
|
|
| 503 | - exception('clientUnityExpected',['key'=>implode(',',$this->unity)])
|
|
| 502 | + if (count($list)>1) {
|
|
| 503 | + exception('clientUnityExpected', ['key'=>implode(',', $this->unity)])
|
|
| 504 | 504 | ->invalidArgument('clientUnityExpected');
|
| 505 | 505 | } |
| 506 | 506 | } |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | {
|
| 516 | 516 | // we use the http method to write |
| 517 | 517 | // the values to the inputs and origin properties. |
| 518 | - foreach($this->clientData as $key=>$value){
|
|
| 518 | + foreach ($this->clientData as $key=>$value) {
|
|
| 519 | 519 | |
| 520 | 520 | //inputs and origin properties |
| 521 | 521 | $this->inputs[$key] = $value; |
@@ -531,9 +531,9 @@ discard block |
||
| 531 | 531 | */ |
| 532 | 532 | private function requestExcept() |
| 533 | 533 | {
|
| 534 | - if(property_exists($this,'requestExcept') && is_array($this->requestExcept)){
|
|
| 535 | - foreach ($this->requestExcept as $item){
|
|
| 536 | - if(isset($this->inputs[$item])){
|
|
| 534 | + if (property_exists($this, 'requestExcept') && is_array($this->requestExcept)) {
|
|
| 535 | + foreach ($this->requestExcept as $item) {
|
|
| 536 | + if (isset($this->inputs[$item])) {
|
|
| 537 | 537 | unset($this->inputs[$item]); |
| 538 | 538 | } |
| 539 | 539 | } |
@@ -546,16 +546,16 @@ discard block |
||
| 546 | 546 | * @param null|string $clientName |
| 547 | 547 | * @return void|mixed |
| 548 | 548 | */ |
| 549 | - public function setClientName($clientName=null) |
|
| 549 | + public function setClientName($clientName = null) |
|
| 550 | 550 | {
|
| 551 | - if(!is_null($clientName) && is_string($clientName)){
|
|
| 551 | + if (!is_null($clientName) && is_string($clientName)) {
|
|
| 552 | 552 | return $this->clientName = $clientName; |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - if(!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])){
|
|
| 555 | + if (!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])) {
|
|
| 556 | 556 | $backTrace = Utils::trace(0)['object']; |
| 557 | 557 | |
| 558 | - if(property_exists($backTrace,'clientName')){
|
|
| 558 | + if (property_exists($backTrace, 'clientName')) {
|
|
| 559 | 559 | $this->clientName = $backTrace->clientName; |
| 560 | 560 | } |
| 561 | 561 | } |
@@ -572,16 +572,16 @@ discard block |
||
| 572 | 572 | |
| 573 | 573 | // we update the input values after |
| 574 | 574 | // we receive and check the saved objects. |
| 575 | - foreach ($clientObjects as $key=>$value){
|
|
| 575 | + foreach ($clientObjects as $key=>$value) {
|
|
| 576 | 576 | |
| 577 | 577 | // we should do key control for group format. |
| 578 | 578 | // this process will allow us to perform key control for 2D array correctly. |
| 579 | - $this->groupsProcess($key,function($key){
|
|
| 579 | + $this->groupsProcess($key, function($key) {
|
|
| 580 | 580 | $this->registerRequestInputs($key); |
| 581 | 581 | unset($this->inputs[$key]); |
| 582 | 582 | }); |
| 583 | 583 | |
| 584 | - if(!in_array($key,$this->generatorList) && isset($clientObjects['origin'][$key])){
|
|
| 584 | + if (!in_array($key, $this->generatorList) && isset($clientObjects['origin'][$key])) {
|
|
| 585 | 585 | |
| 586 | 586 | $this->{$key} = $clientObjects['origin'][$key];
|
| 587 | 587 | $this->inputs[$key] = $this->{$key};
|
@@ -609,11 +609,11 @@ discard block |
||
| 609 | 609 | |
| 610 | 610 | // the request update to be performed using |
| 611 | 611 | // the method name to be used with the http method. |
| 612 | - $this->setRequestInputs($requestMethod,$key); |
|
| 612 | + $this->setRequestInputs($requestMethod, $key); |
|
| 613 | 613 | |
| 614 | 614 | // the request update to be performed using |
| 615 | 615 | // the method name to be used without the http method. |
| 616 | - $this->setRequestInputs($key,$key); |
|
| 616 | + $this->setRequestInputs($key, $key); |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | /** |
@@ -624,28 +624,28 @@ discard block |
||
| 624 | 624 | * |
| 625 | 625 | * @throws ReflectionExceptionAlias |
| 626 | 626 | */ |
| 627 | - private function setRequestInputs($method,$key) |
|
| 627 | + private function setRequestInputs($method, $key) |
|
| 628 | 628 | {
|
| 629 | - if(!in_array($key,$this->generatorList) && method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){
|
|
| 629 | + if (!in_array($key, $this->generatorList) && method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) {
|
|
| 630 | 630 | |
| 631 | 631 | //check annotations for method |
| 632 | - $annotation = app()->resolve(ClientAnnotationManager::class,['request'=>$this]); |
|
| 633 | - $annotation->annotation($method,$key); |
|
| 632 | + $annotation = app()->resolve(ClientAnnotationManager::class, ['request'=>$this]); |
|
| 633 | + $annotation->annotation($method, $key); |
|
| 634 | 634 | |
| 635 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){
|
|
| 635 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) {
|
|
| 636 | 636 | |
| 637 | 637 | $inputKeys = $this->inputs[$key]; |
| 638 | 638 | |
| 639 | 639 | $this->inputs[$key] = []; |
| 640 | - foreach ($inputKeys as $ikey=>$input){
|
|
| 640 | + foreach ($inputKeys as $ikey=>$input) {
|
|
| 641 | 641 | |
| 642 | 642 | $this->{$key}[$ikey] = $input;
|
| 643 | 643 | $keyMethod = $this->{$method}();
|
| 644 | 644 | $this->inputs[$key] = $keyMethod; |
| 645 | 645 | } |
| 646 | 646 | } |
| 647 | - else{
|
|
| 648 | - if(isset($this->inputs[$key])){
|
|
| 647 | + else {
|
|
| 648 | + if (isset($this->inputs[$key])) {
|
|
| 649 | 649 | $keyMethod = $this->{$method}();
|
| 650 | 650 | $this->inputs[$key] = $keyMethod; |
| 651 | 651 | } |
@@ -664,8 +664,8 @@ discard block |
||
| 664 | 664 | // the auto object validate property is the property |
| 665 | 665 | // where all of your request values are automatically validated. |
| 666 | 666 | /** @noinspection PhpParamsInspection */ |
| 667 | - if(property_exists($this,'autoObjectValidate') |
|
| 668 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){
|
|
| 667 | + if (property_exists($this, 'autoObjectValidate') |
|
| 668 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) {
|
|
| 669 | 669 | $this->autoValidate('autoObjectValidate');
|
| 670 | 670 | } |
| 671 | 671 | } |
@@ -141,8 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | if(!is_null($provider = $this->auth->provider($credential))){
|
| 143 | 143 | $query->where($credential,$provider($credentialValue)); |
| 144 | - } |
|
| 145 | - else{
|
|
| 144 | + } else{
|
|
| 146 | 145 | $query->where($credential,$credentialValue); |
| 147 | 146 | } |
| 148 | 147 | } |
@@ -180,8 +179,7 @@ discard block |
||
| 180 | 179 | if(!$update){
|
| 181 | 180 | $this->auth->params['status'] = 0; |
| 182 | 181 | $this->auth->params['exception'] = 'update'; |
| 183 | - } |
|
| 184 | - else{
|
|
| 182 | + } else{
|
|
| 185 | 183 | if(!is_null($after = $this->auth->provider('after'))){
|
| 186 | 184 | if(false === $after($this->auth->params['builder']->first())){
|
| 187 | 185 | $this->auth->params['status'] = 0; |
@@ -216,8 +214,7 @@ discard block |
||
| 216 | 214 | 'device_agent_integer' => crc32(md5($_SERVER['HTTP_USER_AGENT'])), |
| 217 | 215 | 'expire' => $this->auth->getExpire(), |
| 218 | 216 | ]); |
| 219 | - } |
|
| 220 | - else{
|
|
| 217 | + } else{
|
|
| 221 | 218 | |
| 222 | 219 | return DeviceToken::where('user_id',$this->auth->params['authId'])
|
| 223 | 220 | ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT'])))
|
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | {
|
| 52 | 52 | $userId = $manager->getAuth()->params['userId']; |
| 53 | 53 | |
| 54 | - return DeviceToken::where('user_id',$userId)->get();
|
|
| 54 | + return DeviceToken::where('user_id', $userId)->get();
|
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | return DeviceToken::where(function($query) use($token) {
|
| 65 | 65 | |
| 66 | 66 | //where query for token |
| 67 | - $query->where('token_integer',crc32(md5($token)));
|
|
| 68 | - $query->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT'])));
|
|
| 67 | + $query->where('token_integer', crc32(md5($token)));
|
|
| 68 | + $query->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT'])));
|
|
| 69 | 69 | }); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | return DeviceToken::where(function($query) use($token) {
|
| 80 | 80 | |
| 81 | 81 | //where query for token |
| 82 | - $query->where('token_integer',crc32(md5($token)));
|
|
| 83 | - $query->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT'])));
|
|
| 82 | + $query->where('token_integer', crc32(md5($token)));
|
|
| 83 | + $query->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT'])));
|
|
| 84 | 84 | |
| 85 | 85 | }); |
| 86 | 86 | } |
@@ -91,23 +91,23 @@ discard block |
||
| 91 | 91 | * @param null|object $query |
| 92 | 92 | * @return mixed |
| 93 | 93 | */ |
| 94 | - protected function checkPasswordVerify($query=null) |
|
| 94 | + protected function checkPasswordVerify($query = null) |
|
| 95 | 95 | {
|
| 96 | - if(is_null($query) && isset($this->credentials['password'])){
|
|
| 97 | - if(!is_null($password = $this->auth->provider('password'))
|
|
| 98 | - && $password($this->credentials['password'])=='verify'){
|
|
| 96 | + if (is_null($query) && isset($this->credentials['password'])) {
|
|
| 97 | + if (!is_null($password = $this->auth->provider('password'))
|
|
| 98 | + && $password($this->credentials['password'])=='verify') {
|
|
| 99 | 99 | |
| 100 | 100 | $this->password = $this->credentials['password']; |
| 101 | 101 | $this->passwordVerify = true; |
| 102 | - $this->credentials = Arr::removeKey($this->credentials,['password']); |
|
| 102 | + $this->credentials = Arr::removeKey($this->credentials, ['password']); |
|
| 103 | 103 | |
| 104 | 104 | return null; |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if(is_object($query) && $query->count()){
|
|
| 108 | + if (is_object($query) && $query->count()) {
|
|
| 109 | 109 | $password = $query->first()->password; |
| 110 | - if(password_verify($this->password,$password)){
|
|
| 110 | + if (password_verify($this->password, $password)) {
|
|
| 111 | 111 | return $query; |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -137,24 +137,24 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | // with the callback method (eloquent model) |
| 139 | 139 | // we write the where clause. |
| 140 | - foreach ($this->credentials as $credential=>$credentialValue){
|
|
| 140 | + foreach ($this->credentials as $credential=>$credentialValue) {
|
|
| 141 | 141 | |
| 142 | - if(!is_null($provider = $this->auth->provider($credential))){
|
|
| 143 | - $query->where($credential,$provider($credentialValue)); |
|
| 142 | + if (!is_null($provider = $this->auth->provider($credential))) {
|
|
| 143 | + $query->where($credential, $provider($credentialValue)); |
|
| 144 | 144 | } |
| 145 | - else{
|
|
| 146 | - $query->where($credential,$credentialValue); |
|
| 145 | + else {
|
|
| 146 | + $query->where($credential, $credentialValue); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // for the authenticate query, |
| 151 | 151 | // the user can add additional queries by the service provider. |
| 152 | - if(!is_null($addQuery = $this->auth->provider('addQuery'))){
|
|
| 152 | + if (!is_null($addQuery = $this->auth->provider('addQuery'))) {
|
|
| 153 | 153 | $addQuery($query); |
| 154 | 154 | } |
| 155 | 155 | }); |
| 156 | 156 | |
| 157 | - if(false === $this->passwordVerify){
|
|
| 157 | + if (false===$this->passwordVerify) {
|
|
| 158 | 158 | return $query; |
| 159 | 159 | } |
| 160 | 160 | |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | /** |
| 165 | 165 | * @return void|mixed |
| 166 | 166 | */ |
| 167 | - protected function updateToken($token=null) |
|
| 167 | + protected function updateToken($token = null) |
|
| 168 | 168 | {
|
| 169 | 169 | //if query status value is true |
| 170 | - if($this->auth->params['status']){
|
|
| 170 | + if ($this->auth->params['status']) {
|
|
| 171 | 171 | |
| 172 | 172 | // we go to the method that produces |
| 173 | 173 | // the classical token value and get the token value. |
@@ -177,13 +177,13 @@ discard block |
||
| 177 | 177 | // if there is no update, we reset the status value to 0. |
| 178 | 178 | $update = $this->auth->params['builder']->update(['token'=>$this->auth->params['token']]); |
| 179 | 179 | |
| 180 | - if(!$update){
|
|
| 180 | + if (!$update) {
|
|
| 181 | 181 | $this->auth->params['status'] = 0; |
| 182 | 182 | $this->auth->params['exception'] = 'update'; |
| 183 | 183 | } |
| 184 | - else{
|
|
| 185 | - if(!is_null($after = $this->auth->provider('after'))){
|
|
| 186 | - if(false === $after($this->auth->params['builder']->first())){
|
|
| 184 | + else {
|
|
| 185 | + if (!is_null($after = $this->auth->provider('after'))) {
|
|
| 186 | + if (false===$after($this->auth->params['builder']->first())) {
|
|
| 187 | 187 | $this->auth->params['status'] = 0; |
| 188 | 188 | $this->auth->params['exception'] = 'update'; |
| 189 | 189 | } |
@@ -203,14 +203,14 @@ discard block |
||
| 203 | 203 | {
|
| 204 | 204 | $token_integer = null; |
| 205 | 205 | |
| 206 | - if(isset($this->auth->params['token'])){
|
|
| 206 | + if (isset($this->auth->params['token'])) {
|
|
| 207 | 207 | $token_integer = crc32(md5($this->auth->params['token'])); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if(!is_null($token_integer)){
|
|
| 210 | + if (!is_null($token_integer)) {
|
|
| 211 | 211 | |
| 212 | - if(DeviceToken::where('user_id',$this->auth->params['authId'])
|
|
| 213 | - ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT'])))->count()==0){
|
|
| 212 | + if (DeviceToken::where('user_id', $this->auth->params['authId'])
|
|
| 213 | + ->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT'])))->count()==0) {
|
|
| 214 | 214 | |
| 215 | 215 | return DeviceToken::create([ |
| 216 | 216 | 'user_id' => $this->auth->params['authId'], |
@@ -221,10 +221,10 @@ discard block |
||
| 221 | 221 | 'expire' => $this->auth->getExpire(), |
| 222 | 222 | ]); |
| 223 | 223 | } |
| 224 | - else{
|
|
| 224 | + else {
|
|
| 225 | 225 | |
| 226 | - return DeviceToken::where('user_id',$this->auth->params['authId'])
|
|
| 227 | - ->where('device_agent_integer',crc32(md5($_SERVER['HTTP_USER_AGENT'])))
|
|
| 226 | + return DeviceToken::where('user_id', $this->auth->params['authId'])
|
|
| 227 | + ->where('device_agent_integer', crc32(md5($_SERVER['HTTP_USER_AGENT'])))
|
|
| 228 | 228 | ->update([ |
| 229 | 229 | 'token' => $this->auth->params['token'], |
| 230 | 230 | 'token_integer' => $token_integer |
@@ -244,11 +244,11 @@ discard block |
||
| 244 | 244 | {
|
| 245 | 245 | $token_integer = crc32(md5($this->auth->getTokenSentByUser())); |
| 246 | 246 | |
| 247 | - if(!is_null($token_integer)){
|
|
| 247 | + if (!is_null($token_integer)) {
|
|
| 248 | 248 | |
| 249 | - DeviceToken::where('token_integer',$token_integer)->delete();
|
|
| 249 | + DeviceToken::where('token_integer', $token_integer)->delete();
|
|
| 250 | 250 | |
| 251 | - return (DeviceToken::where('token_integer',$token_integer)->count()) ? false : true;
|
|
| 251 | + return (DeviceToken::where('token_integer', $token_integer)->count()) ? false : true;
|
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | {
|
| 25 | 25 | // if the status value is true, |
| 26 | 26 | // we send output generated from the token value. |
| 27 | - if($this->checkStatus()){
|
|
| 27 | + if ($this->checkStatus()) {
|
|
| 28 | 28 | $this->setAuthenticateSuccess(true); |
| 29 | 29 | return true; |
| 30 | 30 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | {
|
| 41 | 41 | // if the status value is true, |
| 42 | 42 | // we send output generated from the token value. |
| 43 | - if($this->checkStatus()){
|
|
| 43 | + if ($this->checkStatus()) {
|
|
| 44 | 44 | return true; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | protected function getResult() |
| 55 | 55 | {
|
| 56 | - $result= []; |
|
| 56 | + $result = []; |
|
| 57 | 57 | |
| 58 | 58 | // if the status value is true, |
| 59 | 59 | // we send output generated from the token value. |
| 60 | - if($this->checkStatus()){
|
|
| 60 | + if ($this->checkStatus()) {
|
|
| 61 | 61 | $result['message'] = 'token success'; |
| 62 | 62 | $result['token'] = $this->params['token']; |
| 63 | 63 | $result['user'] = $this->params['data']; |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @param bool $value |
| 81 | 81 | */ |
| 82 | - private function setAuthenticateSuccess($value=true) |
|
| 82 | + private function setAuthenticateSuccess($value = true) |
|
| 83 | 83 | {
|
| 84 | - if(app()->has('authenticateSuccess')){
|
|
| 84 | + if (app()->has('authenticateSuccess')) {
|
|
| 85 | 85 | app()->terminate('authenticateSuccess');
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - app()->register('authenticateSuccess',$value);
|
|
| 88 | + app()->register('authenticateSuccess', $value);
|
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | \ No newline at end of file |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | |
| 6 | 6 | class User extends Eloquent |
| 7 | 7 | {
|
| 8 | - protected $hidden = ['id','password','token']; |
|
| 8 | + protected $hidden = ['id', 'password', 'token']; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * User constructor. |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @var array |
| 34 | 34 | */ |
| 35 | - public $commandRule=['name','client']; |
|
| 35 | + public $commandRule = ['name', 'client']; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @method create |
@@ -56,35 +56,35 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $this->argument['managerTraitNamespace'] = Utils::getNamespace($this->directory['clientNameDir'].'/'.$name.'Trait.php'); |
| 58 | 58 | |
| 59 | - if(!file_exists($manager = $this->directory['clientNameDir'].'/'.$name.'Manager.php')){
|
|
| 59 | + if (!file_exists($manager = $this->directory['clientNameDir'].'/'.$name.'Manager.php')) {
|
|
| 60 | 60 | $this->touch['client/manager'] = $manager; |
| 61 | 61 | $this->touch['client/managertrait'] = $this->directory['clientNameDir'].'/'.$name.'Trait.php'; |
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if(isset($this->argument['trait'])){
|
|
| 65 | + if (isset($this->argument['trait'])) {
|
|
| 66 | 66 | $this->argument['name'] = $this->argument['trait']; |
| 67 | 67 | |
| 68 | - if(!file_exists($managerCustomTrait = $this->directory['clientNameDir'].'/'.$this->argument['trait'].'Trait.php')){
|
|
| 68 | + if (!file_exists($managerCustomTrait = $this->directory['clientNameDir'].'/'.$this->argument['trait'].'Trait.php')) {
|
|
| 69 | 69 | $this->touch['client/managercustomtrait'] = $managerCustomTrait; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $this->argument['managerTraitNamespace'] = Utils::getNamespace($managerCustomTrait); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if(!file_exists($this->directory['clientNameCreate'].'/Client.php')){
|
|
| 75 | + if (!file_exists($this->directory['clientNameCreate'].'/Client.php')) {
|
|
| 76 | 76 | $this->touch['client/client'] = $this->directory['clientNameCreate'].'/Client.php'; |
| 77 | 77 | $this->touch['client/clientGenerator'] = $this->directory['clientNameCreate'].'/ClientGenerator.php'; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $clientSourceNamespace = Utils::getNamespace($this->directory['clientSource'].'/'.$client.'.php'); |
| 81 | 81 | |
| 82 | - if(!file_exists($clientSourceName = $this->directory['clientSource'].'/'.$client.'.php')){
|
|
| 82 | + if (!file_exists($clientSourceName = $this->directory['clientSource'].'/'.$client.'.php')) {
|
|
| 83 | 83 | $this->touch['client/source'] = $clientSourceName.''; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | |
| 87 | - if(!file_exists($this->directory['clientNameCreate'].'/ClientProvider.php')){
|
|
| 87 | + if (!file_exists($this->directory['clientNameCreate'].'/ClientProvider.php')) {
|
|
| 88 | 88 | $this->touch['client/clientProvider'] = $this->directory['clientNameCreate'].'/ClientProvider.php'; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $nameGeneratorNamespace = Utils::getNamespace($managerPath = $this->directory['clientNameDir'].''.DIRECTORY_SEPARATOR.''.$nameManager.'.php'); |
| 100 | 100 | |
| 101 | - $generator = new Generator(path()->version(),'ClientManager'); |
|
| 101 | + $generator = new Generator(path()->version(), 'ClientManager'); |
|
| 102 | 102 | |
| 103 | 103 | $clientManager = app()->namespace()->version().'\\ClientManager'; |
| 104 | 104 | |
| 105 | 105 | $clientManagerResolve = new $clientManager; |
| 106 | 106 | |
| 107 | - if(!method_exists($clientManagerResolve,strtolower($name))){
|
|
| 107 | + if (!method_exists($clientManagerResolve, strtolower($name))) {
|
|
| 108 | 108 | |
| 109 | 109 | $generator->createMethod([ |
| 110 | 110 | strtolower($name) |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - $nameGenerator = new Generator($this->directory['clientNameDir'],$name.'Manager'); |
|
| 138 | + $nameGenerator = new Generator($this->directory['clientNameDir'], $name.'Manager'); |
|
| 139 | 139 | |
| 140 | 140 | $nameGeneratorNamespaceResolve = new $nameGeneratorNamespace; |
| 141 | 141 | |
| 142 | - if(!method_exists($nameGeneratorNamespaceResolve,strtolower($client))){
|
|
| 142 | + if (!method_exists($nameGeneratorNamespaceResolve, strtolower($client))) {
|
|
| 143 | 143 | |
| 144 | 144 | $nameGenerator->createMethod([ |
| 145 | 145 | strtolower($client) |
@@ -219,8 +219,7 @@ |
||
| 219 | 219 | $table = $this->config['guard'][$this->guard]['deviceTokenRegister']; |
| 220 | 220 | |
| 221 | 221 | app()->register('authenticateDeviceTokenTable',$table);
|
| 222 | - } |
|
| 223 | - else{
|
|
| 222 | + } else{
|
|
| 224 | 223 | app()->register('authenticateDeviceTokenTable','device_tokens');
|
| 225 | 224 | } |
| 226 | 225 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | {
|
| 32 | 32 | $this->config(); |
| 33 | 33 | |
| 34 | - if($this->guard=="default"){
|
|
| 34 | + if ($this->guard=="default") {
|
|
| 35 | 35 | $this->setAuthenticateNeeds(); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | {
|
| 50 | 50 | $this->config = config('authenticate');
|
| 51 | 51 | |
| 52 | - if(!is_null($config = $this->provider('configuration'))){
|
|
| 52 | + if (!is_null($config = $this->provider('configuration'))) {
|
|
| 53 | 53 | $this->config['guard'][$this->guard] = $config($this->config['guard'][$this->guard]); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getAddToWhere() |
| 65 | 65 | {
|
| 66 | - if(isset($this->config['guard'][$this->guard]['addToWhere'])){
|
|
| 66 | + if (isset($this->config['guard'][$this->guard]['addToWhere'])) {
|
|
| 67 | 67 | return $this->config['guard'][$this->guard]['addToWhere']; |
| 68 | 68 | } |
| 69 | 69 | return null; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function getConfigToken() |
| 78 | 78 | {
|
| 79 | - if(isset($this->config['guard'][$this->guard]['token'])){
|
|
| 79 | + if (isset($this->config['guard'][$this->guard]['token'])) {
|
|
| 80 | 80 | return $this->config['guard'][$this->guard]['token']; |
| 81 | 81 | } |
| 82 | 82 | return null; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function provider($key) |
| 172 | 172 | {
|
| 173 | - if(app()->has('authenticate.'.$key) && is_callable($provider = app()->get('authenticate.'.$key))){
|
|
| 173 | + if (app()->has('authenticate.'.$key) && is_callable($provider = app()->get('authenticate.'.$key))) {
|
|
| 174 | 174 | return $provider; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | {
|
| 210 | 210 | $table = $this->config['guard'][$this->guard]['table']; |
| 211 | 211 | |
| 212 | - app()->register('authenticateTable',$table);
|
|
| 212 | + app()->register('authenticateTable', $table);
|
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -219,13 +219,13 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function deviceTokenTable() |
| 221 | 221 | {
|
| 222 | - if(isset($this->config['guard'][$this->guard]['deviceTokenRegister'])){
|
|
| 222 | + if (isset($this->config['guard'][$this->guard]['deviceTokenRegister'])) {
|
|
| 223 | 223 | $table = $this->config['guard'][$this->guard]['deviceTokenRegister']; |
| 224 | 224 | |
| 225 | - app()->register('authenticateDeviceTokenTable',$table);
|
|
| 225 | + app()->register('authenticateDeviceTokenTable', $table);
|
|
| 226 | 226 | } |
| 227 | - else{
|
|
| 228 | - app()->register('authenticateDeviceTokenTable','device_tokens');
|
|
| 227 | + else {
|
|
| 228 | + app()->register('authenticateDeviceTokenTable', 'device_tokens');
|
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | } |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | /** |
| 9 | 9 | * @var array |
| 10 | 10 | */ |
| 11 | - protected $fillable = ['user_id','token','token_integer','device_agent','device_agent_integer','expire']; |
|
| 11 | + protected $fillable = ['user_id', 'token', 'token_integer', 'device_agent', 'device_agent_integer', 'expire']; |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * User constructor. |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param callable $callback |
| 30 | 30 | * @return mixed |
| 31 | 31 | */ |
| 32 | - public function exclude($middleware,callable $callback) |
|
| 32 | + public function exclude($middleware, callable $callback) |
|
| 33 | 33 | {
|
| 34 | 34 | $this->result = true; |
| 35 | 35 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | //if there is exclude method |
| 43 | 43 | //in service middleware class |
| 44 | - if($this->existMethod()){
|
|
| 44 | + if ($this->existMethod()) {
|
|
| 45 | 45 | |
| 46 | 46 | //call exclude method |
| 47 | 47 | /** |
@@ -50,24 +50,24 @@ discard block |
||
| 50 | 50 | $serviceMiddleware = $middleware['class']; |
| 51 | 51 | $excludes = $serviceMiddleware->exclude(); |
| 52 | 52 | |
| 53 | - foreach ($excludes as $excludeKey=>$excludeVal){
|
|
| 54 | - $this->excludeProcess($excludeKey,$excludeVal); |
|
| 53 | + foreach ($excludes as $excludeKey=>$excludeVal) {
|
|
| 54 | + $this->excludeProcess($excludeKey, $excludeVal); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | //return true |
| 59 | - return Utils::returnCallback($this->result,$callback); |
|
| 59 | + return Utils::returnCallback($this->result, $callback); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @param $excludeKey |
| 64 | 64 | * @param $excludeVal |
| 65 | 65 | */ |
| 66 | - private function excludeProcess($excludeKey,$excludeVal) |
|
| 66 | + private function excludeProcess($excludeKey, $excludeVal) |
|
| 67 | 67 | {
|
| 68 | - $this->excludeForAll($excludeKey,$excludeVal,function() use ($excludeKey,$excludeVal){
|
|
| 68 | + $this->excludeForAll($excludeKey, $excludeVal, function() use ($excludeKey, $excludeVal){
|
|
| 69 | 69 | |
| 70 | - if($excludeKey == $this->excludeList['middleware']['middlewareName']){
|
|
| 70 | + if ($excludeKey==$this->excludeList['middleware']['middlewareName']) {
|
|
| 71 | 71 | $this->result = true; |
| 72 | 72 | $this->inArrayExclude($excludeVal); |
| 73 | 73 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | private function existMethod() |
| 82 | 82 | {
|
| 83 | - return Utils::existMethod($this->excludeList['middleware']['class'],'exclude'); |
|
| 83 | + return Utils::existMethod($this->excludeList['middleware']['class'], 'exclude'); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | private function inArrayExclude($exclude) |
| 90 | 90 | {
|
| 91 | - foreach($exclude as $item){
|
|
| 92 | - if(in_array($item,$this->middleware['odds'])){
|
|
| 91 | + foreach ($exclude as $item) {
|
|
| 92 | + if (in_array($item, $this->middleware['odds'])) {
|
|
| 93 | 93 | $this->result = false; |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @param callable $callback |
| 102 | 102 | * @return mixed |
| 103 | 103 | */ |
| 104 | - private function excludeForAll($excludeKey,$excludeVal,callable $callback) |
|
| 104 | + private function excludeForAll($excludeKey, $excludeVal, callable $callback) |
|
| 105 | 105 | {
|
| 106 | 106 | return ($excludeKey=="all") ? $this->inArrayExclude($excludeVal) : call_user_func($callback); |
| 107 | 107 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @var $type |
| 17 | 17 | */ |
| 18 | - public $type='project'; |
|
| 18 | + public $type = 'project'; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @var array |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @var $commandRule |
| 34 | 34 | */ |
| 35 | - public $commandRule=[]; |
|
| 35 | + public $commandRule = []; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @method create |
@@ -47,17 +47,17 @@ discard block |
||
| 47 | 47 | $this->directory['projectDir'] = $this->projectPath(); |
| 48 | 48 | $this->argument['exceptionNamespace'] = app()->namespace()->exception(); |
| 49 | 49 | $this->argument['resourcePath'] = app()->path()->appResourche(); |
| 50 | - $this->argument['testNamespace'] = app()->namespace()->tests(); |
|
| 50 | + $this->argument['testNamespace'] = app()->namespace()->tests(); |
|
| 51 | 51 | |
| 52 | - $recursiveDefaultDirectory = explode("\\",$this->argument['project']);
|
|
| 52 | + $recursiveDefaultDirectory = explode("\\", $this->argument['project']);
|
|
| 53 | 53 | $this->argument['applicationName'] = pos($recursiveDefaultDirectory); |
| 54 | 54 | $recursiveDefaultDirectory[] = 'V1'; |
| 55 | 55 | $recursiveDefaultDirectoryList = []; |
| 56 | 56 | |
| 57 | - foreach (array_slice($recursiveDefaultDirectory,1) as $defaultDirectory){
|
|
| 57 | + foreach (array_slice($recursiveDefaultDirectory, 1) as $defaultDirectory) {
|
|
| 58 | 58 | |
| 59 | - $recursiveDefaultDirectoryList[]=$defaultDirectory; |
|
| 60 | - $this->directory[$defaultDirectory.'Path'] = $this->projectPath().''.implode("/",$recursiveDefaultDirectoryList);
|
|
| 59 | + $recursiveDefaultDirectoryList[] = $defaultDirectory; |
|
| 60 | + $this->directory[$defaultDirectory.'Path'] = $this->projectPath().''.implode("/", $recursiveDefaultDirectoryList);
|
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | //$this->directory['optionalDir'] = $this->optional(); |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | $this->touch['kernel/exception'] = $this->provider().'/ExceptionServiceProvider.php'; |
| 100 | 100 | $this->touch['kernel/response'] = $this->provider().'/ResponseServiceProvider.php'; |
| 101 | 101 | $this->touch['kernel/entity'] = $this->provider().'/EntityServiceProvider.php'; |
| 102 | - $this->touch['kernel/cache'] = $this->provider().'/CacheServiceProvider.php'; |
|
| 102 | + $this->touch['kernel/cache'] = $this->provider().'/CacheServiceProvider.php'; |
|
| 103 | 103 | $this->touch['kernel/authenticate'] = $this->provider().'/AuthenticateServiceProvider.php'; |
| 104 | 104 | $this->touch['kernel/role'] = $this->provider().'/RoleServiceProvider.php'; |
| 105 | 105 | $this->touch['kernel/track'] = $this->provider().'/TrackServiceProvider.php'; |
| 106 | - $this->touch['test/testcase'] = $this->test().'/TestCase.php'; |
|
| 106 | + $this->touch['test/testcase'] = $this->test().'/TestCase.php'; |
|
| 107 | 107 | $this->touch['kernel/consoleevent'] = $this->provider().'/ConsoleEventServiceProvider.php'; |
| 108 | 108 | $this->touch['middleware/authenticate'] = $this->middleware().'/Authenticate.php'; |
| 109 | 109 | $this->touch['middleware/ratelimit'] = $this->middleware().'/RateLimit.php'; |
@@ -121,16 +121,16 @@ discard block |
||
| 121 | 121 | $this->touch['resource/index'] = $this->resource().'/index.html'; |
| 122 | 122 | $this->touch['resource/index'] = $this->resource().'/'.StaticPathModel::$cache.'/index.html'; |
| 123 | 123 | $this->touch['stub/index'] = $this->stub().'/index.html'; |
| 124 | - $this->touch['stub/cccrudapp'] = $this->directory['stubControllerCreateCrudFileDir'] .'/app.stub'; |
|
| 125 | - $this->touch['stub/cccrudconf'] = $this->directory['stubControllerCreateCrudFileDir'] .'/conf.stub'; |
|
| 126 | - $this->touch['stub/cccrudcontrollerfilecrud'] = $this->directory['stubControllerCreateCrudFileDir'] .'/controllerfilecrud.stub'; |
|
| 127 | - $this->touch['stub/cccruddeveloper'] = $this->directory['stubControllerCreateCrudFileDir'] .'/developer.stub'; |
|
| 128 | - $this->touch['stub/cccruddoc'] = $this->directory['stubControllerCreateCrudFileDir'] .'/doc.stub'; |
|
| 129 | - $this->touch['stub/cccruddummy'] = $this->directory['stubControllerCreateCrudFileDir'] .'/dummy.stub'; |
|
| 130 | - $this->touch['stub/cccrudroute'] = $this->directory['stubControllerCreateCrudFileDir'] .'/routecrud.stub'; |
|
| 131 | - $this->touch['stub/cccrudpolicy'] = $this->directory['stubControllerCreateCrudFileDir'] .'/policy.stub'; |
|
| 132 | - $this->touch['stub/cccrudreadme'] = $this->directory['stubControllerCreateCrudFileDir'] .'/readme.stub'; |
|
| 133 | - $this->touch['stub/cccrudresourceindex'] = $this->directory['stubControllerCreateCrudFileDir'] .'/resourceIndex.stub'; |
|
| 124 | + $this->touch['stub/cccrudapp'] = $this->directory['stubControllerCreateCrudFileDir'].'/app.stub'; |
|
| 125 | + $this->touch['stub/cccrudconf'] = $this->directory['stubControllerCreateCrudFileDir'].'/conf.stub'; |
|
| 126 | + $this->touch['stub/cccrudcontrollerfilecrud'] = $this->directory['stubControllerCreateCrudFileDir'].'/controllerfilecrud.stub'; |
|
| 127 | + $this->touch['stub/cccruddeveloper'] = $this->directory['stubControllerCreateCrudFileDir'].'/developer.stub'; |
|
| 128 | + $this->touch['stub/cccruddoc'] = $this->directory['stubControllerCreateCrudFileDir'].'/doc.stub'; |
|
| 129 | + $this->touch['stub/cccruddummy'] = $this->directory['stubControllerCreateCrudFileDir'].'/dummy.stub'; |
|
| 130 | + $this->touch['stub/cccrudroute'] = $this->directory['stubControllerCreateCrudFileDir'].'/routecrud.stub'; |
|
| 131 | + $this->touch['stub/cccrudpolicy'] = $this->directory['stubControllerCreateCrudFileDir'].'/policy.stub'; |
|
| 132 | + $this->touch['stub/cccrudreadme'] = $this->directory['stubControllerCreateCrudFileDir'].'/readme.stub'; |
|
| 133 | + $this->touch['stub/cccrudresourceindex'] = $this->directory['stubControllerCreateCrudFileDir'].'/resourceIndex.stub'; |
|
| 134 | 134 | $this->touch['config/hateoas'] = $this->config().'/Hateoas.php'; |
| 135 | 135 | //$this->touch['config/response'] = $this->config().'/Response.php'; |
| 136 | 136 | $this->touch['config/redis'] = $this->config().'/Redis.php'; |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | $this->touch['app/gitignore'] = $this->projectPath().'/.gitignore'; |
| 155 | 155 | $this->touch['app/composer'] = $this->projectPath().'/composer.json'; |
| 156 | 156 | $this->touch['test/index'] = $this->storage().'/index.html'; |
| 157 | - $this->touch['exception/authenticate'] = $this->directory['exceptionDir'] .'/AuthenticateException.php'; |
|
| 158 | - $this->touch['exception/noinput'] = $this->directory['exceptionDir'] .'/NoInputException.php'; |
|
| 159 | - $this->touch['helpers/general'] = $this->directory['helperDir'] .'/General.php'; |
|
| 157 | + $this->touch['exception/authenticate'] = $this->directory['exceptionDir'].'/AuthenticateException.php'; |
|
| 158 | + $this->touch['exception/noinput'] = $this->directory['exceptionDir'].'/NoInputException.php'; |
|
| 159 | + $this->touch['helpers/general'] = $this->directory['helperDir'].'/General.php'; |
|
| 160 | 160 | |
| 161 | 161 | //set project touch |
| 162 | 162 | $this->file->touch($this); |