| Conditions | 4 |
| Paths | 4 |
| Total Lines | 52 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 23 | public function post_login(Request $request) |
||
| 24 | { |
||
| 25 | $validator = Validator::make($request->all(), |
||
| 26 | [ |
||
| 27 | 'email' => 'required|email', |
||
| 28 | 'password' => 'required' |
||
| 29 | ]); |
||
| 30 | |||
| 31 | if($validator->fails()) |
||
| 32 | { |
||
| 33 | Session::flash('message', 'Data tidak boleh kosong'); |
||
| 34 | return redirect()->back() |
||
| 35 | ->withErrors($validator) |
||
| 36 | ->withInput(); |
||
| 37 | } |
||
| 38 | $credential = [ |
||
| 39 | 'email' => $request->input('email'), |
||
| 40 | 'password' => $request->input('password'), |
||
| 41 | 'ipaddress' => $request->input('ip1').'-'.$request->input('ip2') |
||
| 42 | ]; |
||
| 43 | |||
| 44 | //set session |
||
| 45 | Session(['ipaddress' => $request->input('ip1').'-'.$request->input('ip2')]); |
||
| 46 | |||
| 47 | if(!BantenprovSso::Attempt($credential)) |
||
| 48 | { |
||
| 49 | //dd(BantenprovSso::message()); |
||
| 50 | Session::flash('message', 'terjadi kesalah, login tidak berhasil'); |
||
| 51 | return redirect()->back() |
||
| 52 | ->withErrors(BantenprovSso::message()) |
||
| 53 | ->withInput(); |
||
| 54 | } |
||
| 55 | //dd(BantenprovSso::data()); |
||
| 56 | $data = BantenprovSso::data(); |
||
| 57 | //check data user pada table user |
||
| 58 | $user = User::where('email', $data->email) |
||
| 59 | ->first(); |
||
| 60 | if(count($user) == 0) |
||
| 61 | { |
||
| 62 | //return 'gak ada'; |
||
| 63 | //insert data user |
||
| 64 | $create_user = new User; |
||
| 65 | $create_user->email = $data->email; |
||
| 66 | $create_user->name = $data->name; |
||
| 67 | $create_user->password = $data->password; |
||
| 68 | $create_user->save(); |
||
| 69 | |||
| 70 | return Self::init_login($create_user); |
||
| 71 | } |
||
| 72 | else |
||
| 73 | { |
||
| 74 | return Self::init_login($user); |
||
| 75 | } |
||
| 157 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths