| Conditions | 4 |
| Paths | 8 |
| Total Lines | 63 |
| Code Lines | 34 |
| 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 |
||
| 85 | public function boot(Router $router): void |
||
| 86 | { |
||
| 87 | // Attach request macro |
||
| 88 | $this->attachRequestMacro(); |
||
| 89 | |||
| 90 | // Map bouncer models |
||
| 91 | Bouncer::useUserModel(config('cortex.fort.models.user')); |
||
| 92 | Bouncer::useRoleModel(config('cortex.fort.models.role')); |
||
| 93 | Bouncer::useAbilityModel(config('cortex.fort.models.ability')); |
||
| 94 | |||
| 95 | // Map bouncer tables (users, roles, abilities tables are set through their models) |
||
| 96 | Bouncer::tables([ |
||
| 97 | 'permissions' => config('cortex.fort.tables.permissions'), |
||
| 98 | 'assigned_roles' => config('cortex.fort.tables.assigned_roles'), |
||
| 99 | ]); |
||
| 100 | |||
| 101 | // Bind route models and constrains |
||
| 102 | $router->pattern('role', '[0-9]+'); |
||
| 103 | $router->pattern('ability', '[0-9]+'); |
||
| 104 | $router->pattern('user', '[a-zA-Z0-9_-]+'); |
||
| 105 | $router->pattern('session', '[a-zA-Z0-9]+'); |
||
| 106 | $router->model('role', config('cortex.fort.models.role')); |
||
| 107 | $router->model('user', config('cortex.fort.models.user')); |
||
| 108 | $router->model('ability', config('cortex.fort.models.ability')); |
||
| 109 | $router->model('session', config('cortex.fort.models.session')); |
||
| 110 | |||
| 111 | // Map relations |
||
| 112 | Relation::morphMap([ |
||
| 113 | 'user' => config('cortex.fort.models.user'), |
||
| 114 | 'role' => config('cortex.fort.models.role'), |
||
| 115 | 'ability' => config('cortex.fort.models.ability'), |
||
| 116 | ]); |
||
| 117 | |||
| 118 | // Load resources |
||
| 119 | require __DIR__.'/../../routes/breadcrumbs.php'; |
||
| 120 | $this->loadRoutesFrom(__DIR__.'/../../routes/web.php'); |
||
| 121 | $this->loadViewsFrom(__DIR__.'/../../resources/views', 'cortex/fort'); |
||
| 122 | $this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'cortex/fort'); |
||
| 123 | ! $this->app->runningInConsole() || $this->loadMigrationsFrom(__DIR__.'/../../database/migrations'); |
||
| 124 | $this->app->afterResolving('blade.compiler', function () { |
||
| 125 | require __DIR__.'/../../routes/menus.php'; |
||
| 126 | }); |
||
| 127 | |||
| 128 | // Publish Resources |
||
| 129 | ! $this->app->runningInConsole() || $this->publishResources(); |
||
| 130 | |||
| 131 | // Register event handlers |
||
| 132 | $this->app['events']->subscribe(GenericHandler::class); |
||
| 133 | |||
| 134 | // Register attributes entities |
||
| 135 | ! app()->bound('rinvex.attributes.entities') || app('rinvex.attributes.entities')->push('user'); |
||
| 136 | |||
| 137 | // Override middlware |
||
| 138 | $this->overrideMiddleware($router); |
||
| 139 | |||
| 140 | // Register menus |
||
| 141 | $this->registerMenus(); |
||
| 142 | |||
| 143 | // Share current user instance with all views |
||
| 144 | $this->app['view']->composer('*', function ($view) { |
||
| 145 | $view->with('currentUser', auth()->user()); |
||
| 146 | }); |
||
| 147 | } |
||
| 148 | |||
| 220 |
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.