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