Completed
Push — develop ( 909b54...bbea00 )
by Quang
02:17
created

MigrationPayload::getPrefixedIndexName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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