| Conditions | 11 |
| Paths | 385 |
| Total Lines | 73 |
| Code Lines | 50 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 11 | public function testConfig(){ |
||
| 12 | $ret=[]; |
||
| 13 | $ret['err'] = 0; |
||
| 14 | if(!empty(config('irfa.lockout'))){ |
||
| 15 | if(is_numeric(config('irfa.lockout.login_attemps'))){ |
||
| 16 | $ret['login_attemps'] = '<fg=green>OK'; |
||
| 17 | } else{ |
||
| 18 | |||
| 19 | $ret['err'] +=1; |
||
| 20 | $ret['login_attemps'] ='<fg=yellow>Must be a number'; |
||
| 21 | } |
||
| 22 | |||
| 23 | if(is_bool(config('irfa.lockout.logging'))){ |
||
| 24 | $ret['logging'] = '<fg=green>OK'; |
||
| 25 | } else{ |
||
| 26 | |||
| 27 | $ret['err'] +=1; |
||
| 28 | $ret['logging'] = '<fg=yellow>Must be a Boolean'; |
||
| 29 | } |
||
| 30 | |||
| 31 | if(is_string(config('irfa.lockout.input_name'))){ |
||
| 32 | $ret['input_name'] = '<fg=green>OK'; |
||
| 33 | } else{ |
||
| 34 | |||
| 35 | $ret['err'] +=1; |
||
| 36 | $ret['input_name'] = '<fg=yellow>Must be a String'; |
||
| 37 | } |
||
| 38 | if(is_writable(config('irfa.lockout.lockout_file_path'))){ |
||
| 39 | $ret['lockout_file_path'] = '<fg=green>OK'; |
||
| 40 | } else{ |
||
| 41 | $ret['lockout_file_path'] = '<fg=yellow>Write Permission Denied in '.config('irfa.lockout.lockout_file_path'); |
||
| 42 | } |
||
| 43 | |||
| 44 | if(!empty(config('irfa.lockout.redirect_url'))){ |
||
| 45 | $ret['redirect_url'] = '<fg=green>OK'; |
||
| 46 | } else{ |
||
| 47 | |||
| 48 | $ret['err'] +=1; |
||
| 49 | $ret['redirect_url'] = '<fg=yellow>Must be provided'; |
||
| 50 | } |
||
| 51 | if(is_array(config('irfa.lockout.protected_action_path'))){ |
||
| 52 | $ret['protected_action_path'] = '<fg=green>OK'; |
||
| 53 | } else{ |
||
| 54 | |||
| 55 | $ret['err'] +=1; |
||
| 56 | $ret['protected_action_path'] = '<fg=yellow>Must be array'; |
||
| 57 | } |
||
| 58 | |||
| 59 | if(is_array(config('irfa.lockout.protected_middleware_group'))){ |
||
| 60 | if(!empty(config('irfa.lockout.protected_middleware_group'))){ |
||
| 61 | $ret['protected_middleware_group'] = '<fg=green>OK'; |
||
| 62 | } else{ |
||
| 63 | $ret['err'] +=1; |
||
| 64 | $ret['protected_middleware_group'] = '<fg=yellow>Must be provided'; |
||
| 65 | } |
||
| 66 | } else{ |
||
| 67 | |||
| 68 | $ret['err'] +=1; |
||
| 69 | $ret['protected_middleware_group'] = '<fg=yellow>Must be array'; |
||
| 70 | } |
||
| 71 | if(is_string(config('irfa.lockout.message_name'))){ |
||
| 72 | $ret['message_name'] = '<fg=green>OK'; |
||
| 73 | } else{ |
||
| 74 | |||
| 75 | $ret['err'] +=1; |
||
| 76 | $ret['message_name'] = '<fg=yellow>Must be a String'; |
||
| 77 | } |
||
| 78 | } else{ |
||
| 79 | $ret['err'] +=1; |
||
| 80 | $ret['file'] = "<fg=yellow> Could't find config file. Try to run <fg=cyan>php artisan vendor:publish --tag=lockout-account"; |
||
| 81 | } |
||
| 82 | |||
| 83 | return $ret; |
||
| 84 | } |
||
| 146 |