ContentMigrationsServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Orkhanahmadov\ContentMigrations;
4
5
use Illuminate\Contracts\Events\Dispatcher;
6
use Illuminate\Database\Migrations\DatabaseMigrationRepository;
7
use Illuminate\Database\Migrations\MigrationCreator;
8
use Illuminate\Database\Migrations\Migrator;
9
use Illuminate\Support\ServiceProvider;
10
use Orkhanahmadov\ContentMigrations\Console\InstallCommand;
11
use Orkhanahmadov\ContentMigrations\Console\MigrateCommand;
12
use Orkhanahmadov\ContentMigrations\Console\MigrateMakeCommand;
13
14
class ContentMigrationsServiceProvider extends ServiceProvider
15
{
16
    public function register()
17
    {
18
        $this->app->singleton(InstallCommand::class, function ($app) {
19
            return new InstallCommand(new DatabaseMigrationRepository($app['db'], 'content_migrations'));
20
        });
21
22
        $this->app->singleton(MigrateCommand::class, function ($app) {
23
            return new MigrateCommand(
24
                new Migrator(
25
                    new DatabaseMigrationRepository($app['db'], 'content_migrations'),
26
                    $app['db'],
27
                    $app['files'],
28
                    $app['events']
29
                ),
30
                $app[Dispatcher::class]
0 ignored issues
show
Unused Code introduced by
The call to Orkhanahmadov\ContentMig...eCommand::__construct() has too many arguments starting with $app[Illuminate\Contract...ents\Dispatcher::class]. ( Ignorable by Annotation )

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

30
            return /** @scrutinizer ignore-call */ new MigrateCommand(

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
31
            );
32
        });
33
34
        $this->app->singleton(MigrateMakeCommand::class, function ($app) {
35
            return new MigrateMakeCommand(
36
                new MigrationCreator(
37
                    $app['files'],
38
                    __DIR__ . DIRECTORY_SEPARATOR . 'Console' . DIRECTORY_SEPARATOR . 'stubs'
39
                ),
40
                $app['composer']
41
            );
42
        });
43
    }
44
45
    public function boot()
46
    {
47
        if ($this->app->runningInConsole()) {
48
            $this->commands([
49
                 InstallCommand::class,
50
                 MigrateCommand::class,
51
                 MigrateMakeCommand::class,
52
             ]);
53
        }
54
    }
55
}
56