| Conditions | 6 |
| Paths | 12 |
| Total Lines | 99 |
| Code Lines | 59 |
| 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 |
||
| 46 | public function postLogin() { |
||
| 47 | |||
| 48 | |||
| 49 | // $input = Input::only(array( |
||
| 50 | // 'email', |
||
| 51 | // 'password' |
||
| 52 | // )); |
||
| 53 | |||
| 54 | |||
| 55 | if(Input::get('token')!=''){ |
||
| 56 | $rules = array( |
||
| 57 | 'email' => 'required|email', |
||
| 58 | 'password' => 'required|min:6|regex:/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{1,}$/' |
||
| 59 | ); |
||
| 60 | $messages = array( |
||
| 61 | 'password.regex' => 'The password must containt atleast 1 Upper Case letters[A-Z],1 Lower Case Letter[a-z],1 numeric letter [0-9] and 1 special character.', |
||
| 62 | |||
| 63 | );} |
||
| 64 | else{ |
||
| 65 | $rules = array( |
||
| 66 | 'email' => 'required|email', |
||
| 67 | 'password' => 'required' |
||
| 68 | ); |
||
| 69 | $messages = array( |
||
| 70 | 'password.regex' => 'Invalid Username/Password', |
||
| 71 | |||
| 72 | ); |
||
| 73 | } |
||
| 74 | |||
| 75 | |||
| 76 | $validator = Validator::make(Input::all(), $rules,$messages); |
||
| 77 | |||
| 78 | if ($validator->fails()) { |
||
| 79 | return Response::json(array( |
||
| 80 | 'success' => false, |
||
| 81 | 'errors' => $validator->getMessageBag()->toArray(), |
||
| 82 | 400 |
||
| 83 | )); // 400 being the HTTP code for an invalid request. |
||
| 84 | } else { |
||
| 85 | $token = Input::get('token'); // for invited account |
||
| 86 | if ($token != '') { |
||
| 87 | |||
| 88 | $result = DB::table('invitation_token')->where('token', '=', $token)->first(); |
||
| 89 | if (count($result)>0) {//token was valid and was deleted |
||
| 90 | //Create invited account |
||
| 91 | $userInfo=explode('@',$result['email']); |
||
| 92 | $id = DB::table('users')->insertGetId( |
||
| 93 | ['first_name' => $userInfo[0], 'last_name' => '', 'email' => $result['email'], 'password' => Hash::make(Input::get('password'))] |
||
| 94 | ); |
||
| 95 | DB::table('user_roles')->insert( |
||
| 96 | ['user_id' => $id, 'role_id' => "3"] |
||
| 97 | ); |
||
| 98 | DB::table('team_channel_users')->insert( |
||
| 99 | ['team_channel_name_id' => $result['team_id'], 'user_id' => $id] |
||
| 100 | ); |
||
| 101 | //delete token from database before creating invited account |
||
| 102 | DB::table('invitation_token')->where('token', '=', $token)->delete(); |
||
| 103 | $this->teamRepository->updateNewMemberJoinNotification($result['team_id'],$id); |
||
| 104 | } |
||
| 105 | else{ |
||
| 106 | return Response::json(array( |
||
| 107 | 'success' => false, |
||
| 108 | 'errors' => "Invalid Request", |
||
| 109 | 400 |
||
| 110 | )); |
||
| 111 | } |
||
| 112 | } |
||
| 113 | } |
||
| 114 | |||
| 115 | if (Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password')))) { |
||
| 116 | |||
| 117 | /* Store basic information in session of logged in user */ |
||
| 118 | $role = DB::table('roles') |
||
| 119 | ->leftJoin('user_roles', 'roles.id', '=', 'user_roles.role_id') |
||
| 120 | ->where('user_id', '=', Auth::user()->id)->first(); |
||
| 121 | |||
| 122 | |||
| 123 | $channelName = DB::table('channels') |
||
| 124 | ->where('author_id', '=', Auth::user()->id)->first(); |
||
| 125 | |||
| 126 | Session::put('userId', Auth::user()->id); |
||
| 127 | Session::put('firstName', Auth::user()->first_name); |
||
| 128 | Session::put('lastName', Auth::user()->last_name); |
||
| 129 | Session::put('profilePic', Auth::user()->profile_pic); |
||
| 130 | Session::put('role', $role['role_id']); |
||
| 131 | Session::put('channelId', $channelName['id']); |
||
| 132 | |||
| 133 | return Response::json(array( |
||
| 134 | 'success' => true |
||
| 135 | ), 200); |
||
| 136 | } |
||
| 137 | else{ |
||
| 138 | $errorMsg = array( |
||
| 139 | 'errormsg' => 'Invalid Email or Password' |
||
| 140 | ); |
||
| 141 | return Response::json(array( |
||
| 142 | 'success' => false, |
||
| 143 | 'errors' => $errorMsg, |
||
| 144 | 400 |
||
| 145 | )); // 400 being the HTTP code for an invalid request. |
||
| 215 |
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