MigrateCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 3
b 0
f 0
dl 0
loc 25
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareDatabase() 0 4 2
A handle() 0 7 1
A getMigrationPath() 0 3 1
1
<?php
2
3
namespace Orkhanahmadov\ContentMigrations\Console;
4
5
use Illuminate\Database\Console\Migrations\MigrateCommand as Command;
6
7
class MigrateCommand extends Command
8
{
9
    protected $signature = 'content-migrate';
10
11
    protected $description = 'Run the content migrations';
12
13
    public function handle()
14
    {
15
        $this->prepareDatabase();
16
17
        $this->migrator->setOutput($this->output)->run($this->getMigrationPaths());
18
19
        return 0;
20
    }
21
22
    protected function prepareDatabase()
23
    {
24
        if (! $this->migrator->repositoryExists()) {
25
            $this->call('content-migrate:install');
26
        }
27
    }
28
29
    protected function getMigrationPath()
30
    {
31
        return $this->laravel->databasePath() . DIRECTORY_SEPARATOR . 'content-migrations';
32
    }
33
}
34