| Conditions | 9 |
| Paths | 64 |
| Total Lines | 73 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 8 | ||
| Bugs | 2 | Features | 2 |
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 |
||
| 34 | public function boot(): void |
||
| 35 | { |
||
| 36 | if ($this->app->runningInConsole()) { |
||
| 37 | // Publish config file |
||
| 38 | $this->publishes([ |
||
| 39 | __DIR__ . '/../../config/commentify.php' => config_path('commentify.php'), |
||
| 40 | ], 'commentify-config'); |
||
| 41 | |||
| 42 | $this->publishes([ |
||
| 43 | __DIR__ . '/../../tailwind.config.js' => base_path('tailwind.config.js'), |
||
| 44 | ], 'commentify-tailwind-config'); |
||
| 45 | |||
| 46 | // Publish Tailwind views |
||
| 47 | $this->publishes([ |
||
| 48 | __DIR__ . '/../../resources/views/tailwind' => resource_path('views/vendor/commentify'), |
||
| 49 | ], 'commentify-tailwind-views'); |
||
| 50 | |||
| 51 | // Publish Bootstrap views |
||
| 52 | $this->publishes([ |
||
| 53 | __DIR__ . '/../../resources/views/bootstrap' => resource_path('views/vendor/commentify'), |
||
| 54 | ], 'commentify-bootstrap-views'); |
||
| 55 | |||
| 56 | // Publish Filament views |
||
| 57 | $this->publishes([ |
||
| 58 | __DIR__ . '/../../resources/views/filament' => resource_path('views/vendor/commentify'), |
||
| 59 | ], 'commentify-filament-views'); |
||
| 60 | |||
| 61 | // Publish language files |
||
| 62 | $this->publishes([ |
||
| 63 | __DIR__ . '/../../lang' => resource_path('../lang/vendor/commentify'), |
||
| 64 | ], 'commentify-lang'); |
||
| 65 | |||
| 66 | } |
||
| 67 | |||
| 68 | $migrationPath = realpath(__DIR__ . '/../../database/migrations'); |
||
| 69 | if ($migrationPath && is_dir($migrationPath)) { |
||
| 70 | $this->loadMigrationsFrom($migrationPath); |
||
| 71 | } |
||
| 72 | |||
| 73 | // Load views based on CSS framework |
||
| 74 | $config = $this->app->make('config'); |
||
| 75 | $framework = $config->get('commentify.css_framework', 'tailwind'); |
||
| 76 | |||
| 77 | // Validate framework value |
||
| 78 | if (!in_array($framework, ['tailwind', 'bootstrap'])) { |
||
| 79 | $framework = 'tailwind'; |
||
| 80 | } |
||
| 81 | |||
| 82 | $frameworkPath = __DIR__ . '/../../resources/views/' . $framework; |
||
| 83 | |||
| 84 | if (is_dir($frameworkPath)) { |
||
| 85 | $this->loadViewsFrom($frameworkPath, 'commentify'); |
||
| 86 | } else { |
||
| 87 | // Fallback to tailwind if framework directory doesn't exist |
||
| 88 | $this->loadViewsFrom(__DIR__ . '/../../resources/views/tailwind', 'commentify'); |
||
| 89 | } |
||
| 90 | |||
| 91 | $filamentPath = __DIR__ . '/../../resources/views/filament'; |
||
| 92 | $filamentPathTailwind = __DIR__ . '/../../resources/views/tailwind/filament'; |
||
| 93 | $filamentPathBootstrap = __DIR__ . '/../../resources/views/bootstrap/filament'; |
||
| 94 | |||
| 95 | if (is_dir($filamentPath)) { |
||
| 96 | $this->loadViewsFrom($filamentPath, 'commentify'); |
||
| 97 | } elseif (is_dir($filamentPathTailwind)) { |
||
| 98 | $this->loadViewsFrom($filamentPathTailwind, 'commentify'); |
||
| 99 | } elseif (is_dir($filamentPathBootstrap)) { |
||
| 100 | $this->loadViewsFrom($filamentPathBootstrap, 'commentify'); |
||
| 101 | } |
||
| 102 | |||
| 103 | $this->loadTranslationsFrom(__DIR__ . '/../../lang', 'commentify'); |
||
| 104 | Livewire::component('comments', Comments::class); |
||
| 105 | Livewire::component('comment', Comment::class); |
||
| 106 | Livewire::component('like', Like::class); |
||
| 107 | } |
||
| 109 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.