CreateVersionDefinitionStage   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 1
1
<?php
2
3
namespace Nord\Lumen\Elasticsearch\Pipelines\Stages;
4
5
use Nord\Lumen\Elasticsearch\Pipelines\Payloads\CreateMigrationPayload;
6
use League\Pipeline\StageInterface;
7
8
/**
9
 * Class CreateVersionDefinitionStage
10
 * @package Nord\Lumen\Elasticsearch\Pipelines\Stages
11
 */
12
class CreateVersionDefinitionStage implements StageInterface
13
{
14
15
    /**
16
     * @inheritDoc
17
     */
18
    public function __invoke($payload)
19
    {
20
        /** @var CreateMigrationPayload $payload */
21
22
        // Determine the path to the version definition
23
        $versionPath = $payload->getVersionPath();
24
25
        // Create the version
26
        $configuration          = $payload->getConfiguration();
27
        $configuration['index'] = $payload->getIndexVersionName();
28
29
        file_put_contents($versionPath, '<?php return ' . var_export($configuration, true) . ";\n");
30
31
        return $payload;
32
    }
33
}
34