EnsureIndexConfigurationFileExistsStage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
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 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 11 2
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 EnsureIndexConfigurationFileExistsStage
10
 * @package Nord\Lumen\Elasticsearch\Pipelines\Stages
11
 */
12
class EnsureIndexConfigurationFileExistsStage implements StageInterface
13
{
14
15
    /**
16
     * @inheritDoc
17
     *
18
     * @throws \InvalidArgumentException if the configuration file specified in the payload doesn't exist
19
     */
20
    public function __invoke($payload)
21
    {
22
        /** @var CreateMigrationPayload $payload */
23
        $configurationPath = $payload->getConfigurationPath();
24
        
25
        if (!file_exists($configurationPath)) {
26
            throw new \InvalidArgumentException(sprintf('The specified configuration file %s does not exist',
27
                $configurationPath));
28
        }
29
30
        return $payload;
31
    }
32
}
33