Passed
Push — master ( 042e62...ddba13 )
by Bruno
08:16 queued 04:19
created

ServiceProvider::boot()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 68
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 8
Bugs 0 Features 0
Metric Value
cc 5
eloc 40
c 8
b 0
f 0
nc 6
nop 0
dl 0
loc 68
rs 8.9688

How to fix   Long Method   

Long Method

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:

1
<?php declare(strict_types=1);
2
3
namespace Modelarium\Laravel;
4
5
use Formularium\Factory\AbstractFactory;
6
use Formularium\Factory\DatatypeFactory;
7
use Illuminate\Support\Facades\Event;
8
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
9
use Nuwave\Lighthouse\Events\RegisterDirectiveNamespaces;
10
11
use function Safe\scandir;
12
13
class ServiceProvider extends LaravelServiceProvider
14
{
15
    /**
16
     * Bootstrap the application services.
17
     *
18
     * @return void
19
     */
20
    public function boot(): void
21
    {
22
        /*
23
         * Commands
24
         */
25
        if ($this->app->runningInConsole()) {
26
            $this->commands([
27
                \Modelarium\Laravel\Console\Commands\ModelariumCodeCommand::class,
28
                \Modelarium\Laravel\Console\Commands\ModelariumDatatypeCommand::class,
29
                \Modelarium\Laravel\Console\Commands\ModelariumDirectiveCommand::class,
30
                \Modelarium\Laravel\Console\Commands\ModelariumFrontendCommand::class,
31
                \Modelarium\Laravel\Console\Commands\ModelariumModelCommand::class,
32
                \Modelarium\Laravel\Console\Commands\ModelariumPublishCommand::class,
33
                \Modelarium\Laravel\Console\Commands\ModelariumRenderableCommand::class,
34
                \Modelarium\Laravel\Console\Commands\ModelariumScaffoldCommand::class,
35
                \Modelarium\Laravel\Console\Commands\ModelariumTypeCommand::class,
36
            ]);
37
        }
38
39
        /*
40
         * Namespace registration
41
         */
42
        AbstractFactory::appendBaseNamespace('App\\Modelarium');
43
        DatatypeFactory::registerFactory(
44
            'Modelarium\\Laravel\\Datatypes\\RelationshipFactory::factoryName'
45
        );
46
47
        /*
48
         * Publishing
49
         */
50
        $this->publishes([
51
            //
52
            __DIR__ . '/../Config/modelarium.php' => config_path('modelarium.php'),
0 ignored issues
show
Bug introduced by
The function config_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
            __DIR__ . '/../Config/modelarium.php' => /** @scrutinizer ignore-call */ config_path('modelarium.php'),
Loading history...
53
        ], 'config');
54
55
        $this->publishes([
56
            __DIR__ . '/../Types/Graphql/directives.graphql' => base_path('graphql/modelariumdirectives.graphql'),
0 ignored issues
show
Bug introduced by
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
            __DIR__ . '/../Types/Graphql/directives.graphql' => /** @scrutinizer ignore-call */ base_path('graphql/modelariumdirectives.graphql'),
Loading history...
57
            __DIR__ . '/../Types/Graphql/scalars.graphql' => base_path('graphql/modelariumscalars.graphql'),
58
        ], 'schema');
59
60
        $this->publishes([
61
            __DIR__ . '/Graphql/user.graphql' => base_path('graphql/data/user.graphql'),
62
            __DIR__ . '/Graphql/schema.graphql' => base_path('graphql/schema.graphql'),
63
        ], 'schemabase');
64
65
        $vueStubs = [];
66
        $vueDir = __DIR__ . '/../Frontend/stubs/Vue/';
67
        foreach (scandir($vueDir) as $i) {
68
            if ($i == "." || $i == "..") {
69
                continue;
70
            }
71
            $vueStubs[$vueDir . $i] = base_path('resources/modelarium/stubs/Vue/' . $i);
72
        }
73
        $this->publishes($vueStubs, 'vue');
74
75
        /*
76
         * Events
77
         */
78
        Event::listen(
79
            RegisterDirectiveNamespaces::class,
80
            function (RegisterDirectiveNamespaces $registerDirectiveNamespaces): string {
0 ignored issues
show
Unused Code introduced by
The parameter $registerDirectiveNamespaces 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 ignore-unused  annotation

80
            function (/** @scrutinizer ignore-unused */ RegisterDirectiveNamespaces $registerDirectiveNamespaces): string {

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...
81
                return 'Modelarium\\Laravel\\Lighthouse\\Directives';
82
            }
83
        );
84
        Event::listen(
85
            RegisterDirectiveNamespaces::class,
86
            function (RegisterDirectiveNamespaces $registerDirectiveNamespaces): string {
0 ignored issues
show
Unused Code introduced by
The parameter $registerDirectiveNamespaces 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 ignore-unused  annotation

86
            function (/** @scrutinizer ignore-unused */ RegisterDirectiveNamespaces $registerDirectiveNamespaces): string {

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...
87
                return 'App\\Datatype\\Types';
88
            }
89
        );
90
    }
91
}
92