GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b1b0e4...487ec3 )
by Tom
12:48 queued 11s
created

EnumServiceProvider::bootValidationRules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26

Duplication

Lines 20
Ratio 76.92 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 20
loc 26
ccs 0
cts 0
cp 0
rs 9.504
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Spatie\Enum\Laravel;
4
5
use Illuminate\Contracts\Validation\Validator as ValidatorContract;
6
use Illuminate\Support\Facades\Validator;
7
use Illuminate\Support\ServiceProvider;
8
use Spatie\Enum\Laravel\Commands\MakeEnum;
9
use Spatie\Enum\Laravel\Rules\EnumIndexRule;
10 132
use Spatie\Enum\Laravel\Rules\EnumNameRule;
11
use Spatie\Enum\Laravel\Rules\EnumRule;
12 132
use Spatie\Enum\Laravel\Rules\EnumValueRule;
13
14 132
class EnumServiceProvider extends ServiceProvider
15 132
{
16
    public function boot()
17 132
    {
18
        $this->publishes([
19
            __DIR__.'/../resources/lang' => resource_path('lang/vendor/enum'),
20
        ]);
21
22
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang/', 'enum');
23
24
        $this->bootValidationRules();
25
    }
26
27
    public function register()
28
    {
29
        $this->app->bind('command.make:enum', MakeEnum::class);
30
31
        $this->commands([
32
            'command.make:enum',
33
        ]);
34
    }
35
36
    public function bootValidationRules(): void
37
    {
38 View Code Duplication
        Validator::extend('enum', function (string $attribute, $value, array $parameters, ValidatorContract $validator): bool {
0 ignored issues
show
Unused Code introduced by
The parameter $validator is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
            $enum = $parameters[0] ?? null;
40
41
            return (new EnumRule($enum))->passes($attribute, $value);
42
        });
43
44 View Code Duplication
        Validator::extend('enum_index', function (string $attribute, $value, array $parameters, ValidatorContract $validator): bool {
0 ignored issues
show
Unused Code introduced by
The parameter $validator is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
            $enum = $parameters[0] ?? null;
46
47
            return (new EnumIndexRule($enum))->passes($attribute, $value);
48
        });
49
50 View Code Duplication
        Validator::extend('enum_name', function (string $attribute, $value, array $parameters, ValidatorContract $validator): bool {
0 ignored issues
show
Unused Code introduced by
The parameter $validator is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
            $enum = $parameters[0] ?? null;
52
53
            return (new EnumNameRule($enum))->passes($attribute, $value);
54
        });
55
56 View Code Duplication
        Validator::extend('enum_value', function (string $attribute, $value, array $parameters, ValidatorContract $validator): bool {
0 ignored issues
show
Unused Code introduced by
The parameter $validator is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
57
            $enum = $parameters[0] ?? null;
58
59
            return (new EnumValueRule($enum))->passes($attribute, $value);
60
        });
61
    }
62
}
63