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

MigrationPayload::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace Nord\Lumen\Elasticsearch\Pipelines\Payloads;
4
5
/**
6
 * Class MigrationPayload
7
 * @package Nord\Lumen\Elasticsearch\Pipelines\Payloads
8
 */
9
abstract class MigrationPayload
10
{
11
12
    /**
13
     * @var string
14
     */
15
    protected $configurationPath;
16
17
    /**
18
     * MigrationPayload constructor.
19
     *
20
     * @param string $configurationPath
21
     */
22
    public function __construct($configurationPath)
23
    {
24
        $this->configurationPath = $configurationPath;
25
    }
26
27
    /**
28
     * @return string
29
     */
30
    public function getConfigurationPath()
31
    {
32
        return $this->configurationPath;
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    public function getConfiguration()
39
    {
40
        return include $this->configurationPath;
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    protected function getConfigurationBasePath()
47
    {
48
        return dirname($this->configurationPath);
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getIndexName()
55
    {
56
        return $this->getConfiguration()['index'];
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function getIndexVersionsPath()
63
    {
64
        return sprintf('%s/versions/%s', $this->getConfigurationBasePath(), $this->getIndexName());
65
    }
66
}
67