Conditions | 10 |
Paths | 256 |
Total Lines | 78 |
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 |
||
99 | public function boot(Router $router): void |
||
100 | { |
||
101 | // Attach request macro |
||
102 | $this->attachRequestMacro(); |
||
103 | |||
104 | // Map bouncer models |
||
105 | Bouncer::useRoleModel(config('cortex.auth.models.role')); |
||
106 | Bouncer::useAbilityModel(config('cortex.auth.models.ability')); |
||
107 | |||
108 | // Map bouncer tables (users, roles, abilities tables are set through their models) |
||
109 | Bouncer::tables([ |
||
110 | 'permissions' => config('cortex.auth.tables.permissions'), |
||
111 | 'assigned_roles' => config('cortex.auth.tables.assigned_roles'), |
||
112 | ]); |
||
113 | |||
114 | // Bind route models and constrains |
||
115 | $router->pattern('role', '[a-zA-Z0-9-]+'); |
||
116 | $router->pattern('ability', '[a-zA-Z0-9-]+'); |
||
117 | $router->pattern('session', '[a-zA-Z0-9-]+'); |
||
118 | $router->pattern('admin', '[a-zA-Z0-9-]+'); |
||
119 | $router->pattern('member', '[a-zA-Z0-9-]+'); |
||
120 | $router->pattern('manager', '[a-zA-Z0-9-]+'); |
||
121 | $router->model('role', config('cortex.auth.models.role')); |
||
122 | $router->model('admin', config('cortex.auth.models.admin')); |
||
123 | $router->model('member', config('cortex.auth.models.member')); |
||
124 | $router->model('manager', config('cortex.auth.models.manager')); |
||
125 | $router->model('guardian', config('cortex.auth.models.guardian')); |
||
126 | $router->model('ability', config('cortex.auth.models.ability')); |
||
127 | $router->model('session', config('cortex.auth.models.session')); |
||
128 | |||
129 | // Map relations |
||
130 | Relation::morphMap([ |
||
131 | 'role' => config('cortex.auth.models.role'), |
||
132 | 'admin' => config('cortex.auth.models.admin'), |
||
133 | 'member' => config('cortex.auth.models.member'), |
||
134 | 'manager' => config('cortex.auth.models.manager'), |
||
135 | 'guardian' => config('cortex.auth.models.guardian'), |
||
136 | 'ability' => config('cortex.auth.models.ability'), |
||
137 | ]); |
||
138 | |||
139 | // Load resources |
||
140 | require __DIR__.'/../../routes/breadcrumbs/adminarea.php'; |
||
141 | $this->loadRoutesFrom(__DIR__.'/../../routes/web/adminarea.php'); |
||
142 | $this->loadViewsFrom(__DIR__.'/../../resources/views', 'cortex/auth'); |
||
143 | $this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'cortex/auth'); |
||
144 | $this->app->runningInConsole() || $this->app->afterResolving('blade.compiler', function () { |
||
145 | require __DIR__.'/../../routes/menus/managerarea.php'; |
||
146 | require __DIR__.'/../../routes/menus/tenantarea.php'; |
||
147 | require __DIR__.'/../../routes/menus/adminarea.php'; |
||
148 | require __DIR__.'/../../routes/menus/frontarea.php'; |
||
149 | }); |
||
150 | |||
151 | // Publish Resources |
||
152 | ! $this->app->runningInConsole() || $this->publishesLang('cortex/auth', true); |
||
153 | ! $this->app->runningInConsole() || $this->publishesViews('cortex/auth', true); |
||
154 | ! $this->app->runningInConsole() || $this->publishesConfig('cortex/auth', true); |
||
155 | ! $this->app->runningInConsole() || $this->publishesMigrations('cortex/auth', true); |
||
156 | |||
157 | // Register event handlers |
||
158 | $this->app['events']->subscribe(GenericHandler::class); |
||
159 | |||
160 | // Register attributes entities |
||
161 | ! app()->bound('rinvex.attributes.entities') || app('rinvex.attributes.entities')->push('admin'); |
||
162 | ! app()->bound('rinvex.attributes.entities') || app('rinvex.attributes.entities')->push('member'); |
||
163 | ! app()->bound('rinvex.attributes.entities') || app('rinvex.attributes.entities')->push('manager'); |
||
164 | |||
165 | // Override middlware |
||
166 | $this->overrideMiddleware($router); |
||
167 | |||
168 | // Register menus |
||
169 | $this->registerMenus(); |
||
170 | |||
171 | // Share current user instance with all views |
||
172 | $this->app['view']->composer('*', function ($view) { |
||
173 | ! config('rinvex.tenants.active') || $view->with('currentTenant', config('rinvex.tenants.active')); |
||
174 | $view->with('currentUser', auth()->guard(request()->route('guard'))->user()); |
||
175 | }); |
||
176 | } |
||
177 | |||
219 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.