AdmineticAuthMixins::admineticAuth()   C
last analyzed

Complexity

Conditions 12
Paths 1

Size

Total Lines 68
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 12
eloc 31
nc 1
nop 0
dl 0
loc 68
rs 6.9666
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

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:

1
<?php
2
3
namespace Pratiksh\Adminetic\Mixins;
4
5
class AdmineticAuthMixins
6
{
7
    public function admineticAuth()
8
    {
9
        /**
10
         * Register the typical authentication routes for an application.
11
         *
12
         * @param  array  $options
13
         * @return callable
14
         */
15
16
        return function ($options = []) {
17
            $namespace = "Pratiksh\Adminetic\Http\Controllers";
18
19
            $this->group(['namespace' => $namespace], function () use ($options) {
0 ignored issues
show
Bug introduced by
The method group() does not exist on Pratiksh\Adminetic\Mixins\AdmineticAuthMixins. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
            $this->/** @scrutinizer ignore-call */ 
20
                   group(['namespace' => $namespace], function () use ($options) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
20
                if ($options['home'] ?? true) {
21
                    $this->view('/', 'adminetic::welcome');
0 ignored issues
show
Bug introduced by
The method view() does not exist on Pratiksh\Adminetic\Mixins\AdmineticAuthMixins. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
                    $this->/** @scrutinizer ignore-call */ 
22
                           view('/', 'adminetic::welcome');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
22
                }
23
                // Login Routes...
24
                if ($options['login'] ?? true) {
25
                    $this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
0 ignored issues
show
Bug introduced by
The method get() does not exist on Pratiksh\Adminetic\Mixins\AdmineticAuthMixins. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
                    $this->/** @scrutinizer ignore-call */ 
26
                           get('login', 'Auth\LoginController@showLoginForm')->name('login');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
                    $this->post('login', 'Auth\LoginController@login');
0 ignored issues
show
Bug introduced by
The method post() does not exist on Pratiksh\Adminetic\Mixins\AdmineticAuthMixins. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
                    $this->/** @scrutinizer ignore-call */ 
27
                           post('login', 'Auth\LoginController@login');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
                }
28
29
                // Logout Routes...
30
                if ($options['logout'] ?? true) {
31
                    $this->post('logout', 'Auth\LoginController@logout')->name('logout');
32
                }
33
34
                // Registration Routes...
35
                if ($options['register'] ?? true) {
36
                    $this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
37
                    $this->post('register', 'Auth\RegisterController@register');
38
                }
39
40
                // Password Reset Routes...
41
                if ($options['reset'] ?? true) {
42
                    $this->resetPassword();
43
                }
44
45
                // Password Confirmation Routes...
46
                if (
47
                    $options['confirm'] ??
48
                    class_exists($this->prependGroupNamespace('Auth\ConfirmPasswordController'))
0 ignored issues
show
Bug introduced by
The method prependGroupNamespace() does not exist on Pratiksh\Adminetic\Mixins\AdmineticAuthMixins. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
                    class_exists($this->/** @scrutinizer ignore-call */ prependGroupNamespace('Auth\ConfirmPasswordController'))

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
                ) {
50
                    $this->confirmPassword();
51
                }
52
53
                // Email Verification Routes...
54
                if ($options['verify'] ?? false) {
55
                    $this->emailVerification();
56
                }
57
58
                // Socialite Login
59
60
                /* OAuth Routes */
61
                if (config('adminetic.enable_socialite', false)) {
62
                    if (config('adminetic.github_socialite', true)) {
63
                        $this->get('sign-in/github', 'Admin\SocialiteController@github')->name('sign_in_github');
64
                        $this->get('sign-in/github/redirect', 'Admin\SocialiteController@githubRedirect')->name('sign_in_github_redirect');
65
                    }
66
67
                    if (config('adminetic.facebook_socialite', true)) {
68
                        $this->get('sign-in/facebook', 'Admin\SocialiteController@facebook')->name('sign_in_facebook');
69
                        $this->get('sign-in/facebook/redirect', 'Admin\SocialiteController@facebookRedirect')->name('sign_in_facebook_redirect');
70
                    }
71
72
                    if (config('adminetic.google_socialite', true)) {
73
                        $this->get('sign-in/google', 'Admin\SocialiteController@google')->name('sign_in_google');
74
                        $this->get('sign-in/google/redirect', 'Admin\SocialiteController@googleRedirect')->name('sign_in_google_redirect');
75
                    }
76
                }
77
            });
78
        };
79
    }
80
81
    /**
82
     * Register the typical reset password routes for an application.
83
     *
84
     * @return callable
85
     */
86
    public function resetPassword()
87
    {
88
        return function () {
89
            $this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
90
            $this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
91
            $this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
92
            $this->post('password/reset', 'Auth\ResetPasswordController@reset')->name('password.update');
93
        };
94
    }
95
96
    /**
97
     * Register the typical confirm password routes for an application.
98
     *
99
     * @return callable
100
     */
101
    public function confirmPassword()
102
    {
103
        return function () {
104
            $this->get('password/confirm', 'Auth\ConfirmPasswordController@showConfirmForm')->name('password.confirm');
105
            $this->post('password/confirm', 'Auth\ConfirmPasswordController@confirm');
106
        };
107
    }
108
109
    /**
110
     * Register the typical email verification routes for an application.
111
     *
112
     * @return callable
113
     */
114
    public function emailVerification()
115
    {
116
        return function () {
117
            $this->get('email/verify', 'Auth\VerificationController@show')->name('verification.notice');
118
            $this->get('email/verify/{id}/{hash}', 'Auth\VerificationController@verify')->name('verification.verify');
119
            $this->post('email/resend', 'Auth\VerificationController@resend')->name('verification.resend');
120
        };
121
    }
122
}
123