Completed
Pull Request — develop (#39)
by Sam
02:08
created

CreateMigrationCommand   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
dl 0
loc 32
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 14 1
1
<?php
2
3
namespace Nord\Lumen\Elasticsearch\Console;
4
5
use Illuminate\Console\Command;
6
use League\Pipeline\Pipeline;
7
use Nord\Lumen\Elasticsearch\Pipelines\Payloads\CreateMigrationPayload;
8
use Nord\Lumen\Elasticsearch\Pipelines\Stages\CreateVersionDefinitionStage;
9
use Nord\Lumen\Elasticsearch\Pipelines\Stages\EnsureIndexConfigurationFileExistsStage;
10
use Nord\Lumen\Elasticsearch\Pipelines\Stages\EnsureIndexVersionsDirectoryExists;
11
12
/**
13
 * Class CreateMigrationCommand
14
 * @package Nord\Lumen\Elasticsearch\Commands\Migrations
15
 */
16
class CreateMigrationCommand extends Command
17
{
18
19
    /**
20
     * @var string
21
     */
22
    protected $signature = 'search:migrations:create {config : The path to the index configuration file}';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = 'Creates a new migration using the specified index configuration';
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function handle()
35
    {
36
        $configurationPath = $this->argument('config');
37
38
        $pipeline = new Pipeline([
39
            new EnsureIndexConfigurationFileExistsStage(),
40
            new EnsureIndexVersionsDirectoryExists(),
41
            new CreateVersionDefinitionStage(),
42
        ]);
43
44
        $payload = new CreateMigrationPayload($configurationPath);
0 ignored issues
show
Bug introduced by
It seems like $configurationPath can also be of type array; however, parameter $configurationPath of Nord\Lumen\Elasticsearch...nPayload::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

44
        $payload = new CreateMigrationPayload(/** @scrutinizer ignore-type */ $configurationPath);
Loading history...
45
        $pipeline->process($payload);
46
47
        $this->output->writeln('Created ' . $payload->getVersionName());
48
    }
49
}
50