Conditions | 4 |
Paths | 4 |
Total Lines | 61 |
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 |
||
13 | public function boot() |
||
14 | { |
||
15 | /* |
||
16 | * Optional methods to load your package assets |
||
17 | */ |
||
18 | // $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-events-calendar'); |
||
19 | // $this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-events-calendar'); |
||
20 | // $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
||
21 | // $this->loadRoutesFrom(__DIR__.'/routes.php'); |
||
22 | |||
23 | if ($this->app->runningInConsole()) { |
||
24 | $this->publishes([ |
||
25 | __DIR__.'/../config/config.php' => config_path('laravel-events-calendar.php'), |
||
26 | ], 'config'); |
||
27 | |||
28 | // Publishing the views. |
||
29 | /*$this->publishes([ |
||
30 | __DIR__.'/../resources/views' => resource_path('views/vendor/laravel-events-calendar'), |
||
31 | ], 'views');*/ |
||
32 | |||
33 | // Publishing assets. |
||
34 | /*$this->publishes([ |
||
35 | __DIR__.'/../resources/assets' => public_path('vendor/laravel-events-calendar'), |
||
36 | ], 'assets');*/ |
||
37 | |||
38 | // Publishing the translation files. |
||
39 | /*$this->publishes([ |
||
40 | __DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-events-calendar'), |
||
41 | ], 'lang');*/ |
||
42 | |||
43 | // Registering package commands. |
||
44 | // $this->commands([]); |
||
45 | |||
46 | |||
47 | /* - Migrations - |
||
48 | create a migration instance for each .php.stub file eg. |
||
49 | create_continents_table.php.stub ---> 2019_04_28_190434761474_create_continents_table.php |
||
50 | */ |
||
51 | $migrations = [ |
||
52 | 'CreateQuotesTable' => 'create_continents_table', |
||
53 | 'CreateCountriesTable' => 'create_countries_table', |
||
54 | 'CreateEventHasOrganizersTable' => 'create_event_has_organizers_table', |
||
55 | 'CreateEventHasTeachersTable' => 'create_event_has_teachers_table', |
||
56 | 'CreateEventsTable' => 'create_events_table', |
||
57 | 'CreateOrganizersTable' => 'create_organizers_table', |
||
58 | 'CreateEventCategoriesTable' => 'event_categories_table', |
||
59 | 'CreateEventRepetitionsTable' => 'event_repetitions_table', |
||
60 | 'CreateEventVenuesTable' => 'event_venues', |
||
61 | ]; |
||
62 | |||
63 | foreach ($migrations as $migrationFunctionName => $migrationFileName) { |
||
64 | if (! class_exists($migrationFunctionName)) { |
||
65 | $this->publishes([ |
||
66 | __DIR__.'/../database/migrations/'.$migrationFileName.'.php.stub' => database_path('migrations/'.Carbon::now()->format('Y_m_d_Hmsu').'_'.$migrationFileName.'.php'), |
||
|
|||
67 | ], 'migrations'); |
||
68 | } |
||
69 | } |
||
70 | |||
71 | |||
72 | } |
||
73 | } |
||
74 | |||
89 |
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: