MigrateInstallCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Schnittstabil\Dartisan\Commands;
4
5
use Garden\Cli\Cli;
6
use Garden\Cli\Args;
7
use Illuminate\Database\Migrations\MigrationRepositoryInterface;
8
use Schnittstabil\Dartisan\OutputInterface;
9
10
class MigrateInstallCommand extends Command
11
{
12
    use DatabaseAwareCommandTrait;
13
    use MigrationAwareCommandTrait;
14
15
    public static $name = 'migrate:install';
16
    protected $repository;
17
18
    public function __construct(
19
        Args $args,
20
        OutputInterface $output,
21
        MigrationRepositoryInterface $repository
22
    ) {
23
        parent::__construct($args, $output);
24
        $this->repository = $repository;
25
    }
26
27
    public function run()
28
    {
29
        if ($this->repository->repositoryExists()) {
30
            $this->output->info('Migration table already exists.');
0 ignored issues
show
Bug introduced by
The method info cannot be called on $this->output (of type callable).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
31
32
            return 0;
33
        }
34
35
        $this->repository->createRepository();
36
        $this->output->info('Migration table created successfully.');
0 ignored issues
show
Bug introduced by
The method info cannot be called on $this->output (of type callable).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
37
38
        return 0;
39
    }
40
41 View Code Duplication
    public static function register(Cli $cli)
42
    {
43
        $cli = static::registerDatabaseOpts($cli);
44
        $cli = static::registerMigrationOpts($cli);
45
46
        return $cli
47
            ->command(static::$name)
48
            ->description('Create the migration repository.');
49
    }
50
}
51