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
Pull Request — master (#13)
by Tom
06:11
created

EnumServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Spatie\Enum\Laravel;
4
5
use Illuminate\Support\ServiceProvider;
6
use Spatie\Enum\Laravel\Rules\EnumRule;
7
use Illuminate\Support\Facades\Validator;
8
use Spatie\Enum\Laravel\Commands\MakeEnum;
9
use Spatie\Enum\Laravel\Rules\EnumNameRule;
10
use Spatie\Enum\Laravel\Rules\EnumIndexRule;
11
use Spatie\Enum\Laravel\Rules\EnumValueRule;
12
use Illuminate\Contracts\Validation\Validator as ValidatorContract;
13
14
class EnumServiceProvider extends ServiceProvider
15
{
16 256
    public function boot()
17
    {
18 256
        $this->publishes([
19 256
            __DIR__.'/../resources/lang' => resource_path('lang/vendor/enum'),
20
        ]);
21
22 256
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang/', 'enum');
23
24 256
        $this->bootValidationRules();
25 256
    }
26
27 256
    public function register()
28
    {
29 256
        $this->app->bind('command.make:enum', MakeEnum::class);
30
31 256
        $this->commands([
32 256
            'command.make:enum',
33
        ]);
34 256
    }
35
36 256
    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 8
            $enum = $parameters[0] ?? null;
40
41 8
            return (new EnumRule($enum))->passes($attribute, $value);
42 256
        });
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 8
            $enum = $parameters[0] ?? null;
46
47 8
            return (new EnumIndexRule($enum))->passes($attribute, $value);
48 256
        });
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 8
            $enum = $parameters[0] ?? null;
52
53 8
            return (new EnumNameRule($enum))->passes($attribute, $value);
54 256
        });
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 8
            $enum = $parameters[0] ?? null;
58
59 8
            return (new EnumValueRule($enum))->passes($attribute, $value);
60 256
        });
61 256
    }
62
}
63