Conditions | 7 |
Paths | 5 |
Total Lines | 56 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | 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 |
||
46 | private function redirectSocialite($driver) |
||
47 | { |
||
48 | $socialiteuser = Socialite::driver($driver)->stateless()->user(); |
||
49 | |||
50 | $user = User::where('email', $socialiteuser->email)->first(); |
||
51 | |||
52 | if (! isset($user)) { |
||
53 | $user = User::create([ |
||
54 | 'name' => $socialiteuser->name, |
||
55 | 'email' => $socialiteuser->email, |
||
56 | 'password' => Hash::make(Str::random(24)), |
||
57 | ]); |
||
58 | // Assigning Default Role to New User |
||
59 | $default_user_role = config('adminetic.default_user_role', 'user'); |
||
60 | $default_user_role_level = config('adminetic.default_user_role_level', 1); |
||
61 | $role = Role::where('name', $default_user_role)->first(); |
||
62 | if ($role) { |
||
63 | $user->roles()->attach($role); |
||
64 | } else { |
||
65 | Role::create([ |
||
66 | 'name' => $default_user_role, |
||
67 | 'description' => 'Default role for newly registered user.', |
||
68 | 'level' => $default_user_role_level, |
||
69 | ]); |
||
70 | } |
||
71 | // Creating Profile |
||
72 | $user->profile()->create([ |
||
73 | 'username' => $socialiteuser->user->nickname ?? 'N/A', |
||
74 | 'address' => $socialiteuser->location ?? 'N/A', |
||
75 | 'profile_pic' => $socialiteuser->getAvatar(), |
||
76 | ]); |
||
77 | |||
78 | // Creating Preference |
||
79 | $preferences = Preference::all(); |
||
80 | if (isset($preferences)) { |
||
81 | foreach ($preferences as $preference) { |
||
82 | if (! isset($preference->roles)) { |
||
83 | $user->preferences()->attach($preference->id, [ |
||
84 | 'enabled' => $preference->active, |
||
85 | ]); |
||
86 | } else { |
||
87 | if (array_intersect($user->roles->pluck('id')->toArray(), $preference->roles) != null) { |
||
88 | $user->preferences()->attach($preference->id, [ |
||
89 | 'enabled' => $preference->active, |
||
90 | ]); |
||
91 | } |
||
92 | } |
||
93 | } |
||
94 | } |
||
95 | Auth::login($user, true); |
||
96 | |||
97 | return redirect(adminRedirectRoute(config('adminetic.oauth_redirect_route_name', 'dashboard'))); |
||
98 | } else { |
||
99 | Auth::login($user, true); |
||
100 | |||
101 | return redirect(adminRedirectRoute(config('adminetic.oauth_redirect_route_name', 'dashboard'))); |
||
102 | } |
||
105 |
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