CreateIndexStage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 8 1
1
<?php
2
3
namespace Nord\Lumen\Elasticsearch\Pipelines\Stages;
4
5
use League\Pipeline\StageInterface;
6
use Nord\Lumen\Elasticsearch\Contracts\ElasticsearchServiceContract;
7
use Nord\Lumen\Elasticsearch\Pipelines\Payloads\ApplyMigrationPayload;
8
9
/**
10
 * Class CreateIndexStage
11
 * @package Nord\Lumen\Elasticsearch\Pipelines\Stages
12
 */
13
class CreateIndexStage implements StageInterface
14
{
15
16
    /**
17
     * @var ElasticsearchServiceContract
18
     */
19
    private $elasticsearchService;
20
21
    /**
22
     * CheckIndexExistsStage constructor.
23
     *
24
     * @param ElasticsearchServiceContract $elasticsearchService
25
     */
26
    public function __construct(ElasticsearchServiceContract $elasticsearchService)
27
    {
28
        $this->elasticsearchService = $elasticsearchService;
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34
    public function __invoke($payload)
35
    {
36
        /** @var ApplyMigrationPayload $payload */
37
        $params = $payload->getPrefixedTargetConfiguration();
38
39
        $this->elasticsearchService->indices()->create($params);
40
41
        return $payload;
42
    }
43
}
44