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 (#7)
by Tom
04:44
created

EnumServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 55.56%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 36
ccs 10
cts 18
cp 0.5556
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 10 1
A registerRequestTransformMacro() 0 22 4
1
<?php
2
3
namespace Spatie\Enum\Laravel;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Support\ServiceProvider;
7
use Spatie\Enum\Laravel\Commands\MakeEnum;
8
9
class EnumServiceProvider extends ServiceProvider
10
{
11 132
    public function register()
12
    {
13 132
        $this->app->bind('command.make:enum', MakeEnum::class);
14
15 132
        $this->commands([
16 132
            'command.make:enum',
17
        ]);
18
19 132
        $this->registerRequestTransformMacro();
20 132
    }
21
22 132
    public function registerRequestTransformMacro()
23
    {
24 132
        if (! Request::hasMacro('transformEnums')) {
25
            Request::macro('transformEnums', function (array $transformations) {
26
                /** @var Request $request */
27
                $request = $this;
28
29
                foreach ($transformations as $key => $enumClass) {
30
                    if (empty($request[$key])) {
31
                        continue;
32
                    }
33
34
                    $request[$key] = forward_static_call(
35
                        $enumClass.'::make',
36
                        $request[$key]
37
                    );
38
                }
39
40
                return $this;
41 4
            });
42
        }
43 132
    }
44
}
45