biiiiiigmonster /
laravel-enum
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace BiiiiiigMonster\LaravelEnum; |
||||
| 4 | |||||
| 5 | use BiiiiiigMonster\LaravelEnum\Commands\EnumMakeCommand; |
||||
| 6 | use BiiiiiigMonster\LaravelEnum\Commands\EnumMetaMakeCommand; |
||||
| 7 | use BiiiiiigMonster\LaravelEnum\Commands\EnumPhpdocCommand; |
||||
| 8 | use BiiiiiigMonster\LaravelEnum\Rules\Enum; |
||||
| 9 | use BiiiiiigMonster\LaravelEnum\Rules\EnumMeta; |
||||
| 10 | use Illuminate\Support\Facades\Validator; |
||||
| 11 | use Illuminate\Support\ServiceProvider; |
||||
| 12 | |||||
| 13 | class EnumServiceProvider extends ServiceProvider |
||||
| 14 | { |
||||
| 15 | const LANG_NAMESPACE = 'enum'; |
||||
| 16 | |||||
| 17 | public function boot(): void |
||||
| 18 | { |
||||
| 19 | $this->bootCommands(); |
||||
| 20 | $this->bootTranslations(); |
||||
| 21 | $this->bootValidators(); |
||||
| 22 | } |
||||
| 23 | |||||
| 24 | private function bootCommands(): void |
||||
| 25 | { |
||||
| 26 | $this->publishes([ |
||||
| 27 | __DIR__.'/Commands/stubs' => $this->app->basePath('stubs'), |
||||
| 28 | ], 'stubs'); |
||||
| 29 | |||||
| 30 | if ($this->app->runningInConsole()) { |
||||
| 31 | $this->commands([ |
||||
| 32 | EnumPhpdocCommand::class, |
||||
| 33 | EnumMakeCommand::class, |
||||
| 34 | EnumMetaMakeCommand::class, |
||||
| 35 | ]); |
||||
| 36 | } |
||||
| 37 | } |
||||
| 38 | |||||
| 39 | private function bootValidators(): void |
||||
| 40 | { |
||||
| 41 | Validator::extend('enumerate', function ($attribute, $value, $parameters, $validator) { |
||||
|
0 ignored issues
–
show
|
|||||
| 42 | return (new Enum(...$parameters))->passes($attribute, $value); |
||||
|
0 ignored issues
–
show
$parameters is expanded, but the parameter $enum of BiiiiiigMonster\LaravelE...les\Enum::__construct() does not expect variable arguments.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 43 | }, trans(static::LANG_NAMESPACE.'::validations.enumerate')); |
||||
| 44 | |||||
| 45 | Validator::extend('enum_meta', function ($attribute, $value, $parameters, $validator) { |
||||
|
0 ignored issues
–
show
The parameter
$validator is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 46 | return (new EnumMeta(...$parameters))->passes($attribute, $value); |
||||
|
0 ignored issues
–
show
$parameters is expanded, but the parameter $enum of BiiiiiigMonster\LaravelE...EnumMeta::__construct() does not expect variable arguments.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 47 | }, trans(static::LANG_NAMESPACE.'::validations.enum_meta')); |
||||
| 48 | } |
||||
| 49 | |||||
| 50 | private function bootTranslations(): void |
||||
| 51 | { |
||||
| 52 | $this->publishes([ |
||||
| 53 | __DIR__.'/../lang' => $this->app->langPath('vendor/'.static::LANG_NAMESPACE), |
||||
| 54 | ], 'translations'); |
||||
| 55 | |||||
| 56 | $this->loadTranslationsFrom(__DIR__.'/../lang', static::LANG_NAMESPACE); |
||||
| 57 | } |
||||
| 58 | } |
||||
| 59 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.