| Conditions | 12 |
| Paths | 256 |
| Total Lines | 79 |
| 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 |
||
| 100 | public function boot(Router $router): void |
||
| 101 | { |
||
| 102 | // Attach request macro |
||
| 103 | $this->attachRequestMacro(); |
||
| 104 | |||
| 105 | // Map bouncer models |
||
| 106 | Bouncer::useRoleModel(config('cortex.auth.models.role')); |
||
| 107 | Bouncer::useAbilityModel(config('cortex.auth.models.ability')); |
||
| 108 | |||
| 109 | // Map bouncer tables (users, roles, abilities tables are set through their models) |
||
| 110 | Bouncer::tables([ |
||
| 111 | 'permissions' => config('cortex.auth.tables.permissions'), |
||
| 112 | 'assigned_roles' => config('cortex.auth.tables.assigned_roles'), |
||
| 113 | ]); |
||
| 114 | |||
| 115 | // Bind route models and constrains |
||
| 116 | $router->pattern('role', '[a-zA-Z0-9-]+'); |
||
| 117 | $router->pattern('ability', '[a-zA-Z0-9-]+'); |
||
| 118 | $router->pattern('session', '[a-zA-Z0-9-]+'); |
||
| 119 | $router->pattern('admin', '[a-zA-Z0-9-]+'); |
||
| 120 | $router->pattern('member', '[a-zA-Z0-9-]+'); |
||
| 121 | $router->pattern('manager', '[a-zA-Z0-9-]+'); |
||
| 122 | $router->model('role', config('cortex.auth.models.role')); |
||
| 123 | $router->model('admin', config('cortex.auth.models.admin')); |
||
| 124 | $router->model('member', config('cortex.auth.models.member')); |
||
| 125 | $router->model('manager', config('cortex.auth.models.manager')); |
||
| 126 | $router->model('guardian', config('cortex.auth.models.guardian')); |
||
| 127 | $router->model('ability', config('cortex.auth.models.ability')); |
||
| 128 | $router->model('session', config('cortex.auth.models.session')); |
||
| 129 | |||
| 130 | // Map relations |
||
| 131 | Relation::morphMap([ |
||
| 132 | 'role' => config('cortex.auth.models.role'), |
||
| 133 | 'admin' => config('cortex.auth.models.admin'), |
||
| 134 | 'member' => config('cortex.auth.models.member'), |
||
| 135 | 'manager' => config('cortex.auth.models.manager'), |
||
| 136 | 'guardian' => config('cortex.auth.models.guardian'), |
||
| 137 | 'ability' => config('cortex.auth.models.ability'), |
||
| 138 | ]); |
||
| 139 | |||
| 140 | // Load resources |
||
| 141 | $this->loadRoutesFrom(__DIR__.'/../../routes/web/adminarea.php'); |
||
| 142 | $this->loadRoutesFrom(__DIR__.'/../../routes/web/frontarea.php'); |
||
| 143 | $this->loadRoutesFrom(__DIR__.'/../../routes/web/managerarea.php'); |
||
| 144 | $this->loadRoutesFrom(__DIR__.'/../../routes/web/tenantarea.php'); |
||
| 145 | $this->loadViewsFrom(__DIR__.'/../../resources/views', 'cortex/auth'); |
||
| 146 | $this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'cortex/auth'); |
||
| 147 | $this->app->runningInConsole() || $this->app->afterResolving('blade.compiler', function () { |
||
| 148 | $accessarea = $this->app['request']->route('accessarea'); |
||
| 149 | ! file_exists($menus = __DIR__."/../../routes/menus/{$accessarea}.php") || require $menus; |
||
| 150 | ! file_exists($breadcrumbs = __DIR__."/../../routes/breadcrumbs/{$accessarea}.php") || require $breadcrumbs; |
||
| 151 | }); |
||
| 152 | |||
| 153 | // Publish Resources |
||
| 154 | ! $this->app->runningInConsole() || $this->publishesLang('cortex/auth', true); |
||
| 155 | ! $this->app->runningInConsole() || $this->publishesViews('cortex/auth', true); |
||
| 156 | ! $this->app->runningInConsole() || $this->publishesConfig('cortex/auth', true); |
||
| 157 | ! $this->app->runningInConsole() || $this->publishesMigrations('cortex/auth', true); |
||
| 158 | |||
| 159 | // Register event handlers |
||
| 160 | $this->app['events']->subscribe(GenericHandler::class); |
||
| 161 | |||
| 162 | // Register attributes entities |
||
| 163 | ! app()->bound('rinvex.attributes.entities') || app('rinvex.attributes.entities')->push('admin'); |
||
| 164 | ! app()->bound('rinvex.attributes.entities') || app('rinvex.attributes.entities')->push('member'); |
||
| 165 | ! app()->bound('rinvex.attributes.entities') || app('rinvex.attributes.entities')->push('manager'); |
||
| 166 | |||
| 167 | // Override middlware |
||
| 168 | $this->overrideMiddleware($router); |
||
| 169 | |||
| 170 | // Register menus |
||
| 171 | $this->registerMenus(); |
||
| 172 | |||
| 173 | // Share current user instance with all views |
||
| 174 | $this->app['view']->composer('*', function ($view) { |
||
| 175 | ! config('rinvex.tenants.active') || $view->with('currentTenant', config('rinvex.tenants.active')); |
||
| 176 | $view->with('currentUser', auth()->guard(request()->route('guard'))->user()); |
||
|
|
|||
| 177 | }); |
||
| 178 | } |
||
| 179 | |||
| 222 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: