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

MigrationPayload   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 9
c 1
b 0
f 0
dl 0
loc 64
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigurationBasePath() 0 3 1
A getPrefixedIndexName() 0 3 1
A getIndexName() 0 3 1
A getIndexVersionsPath() 0 3 1
A __construct() 0 3 1
A getConfiguration() 0 3 1
A getConfigurationPath() 0 3 1
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