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

CreateMigrationPayload   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
dl 0
loc 40
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getVersionPath() 0 3 1
A __construct() 0 6 1
A getIndexVersionName() 0 3 1
A getVersionName() 0 3 1
1
<?php
2
3
namespace Nord\Lumen\Elasticsearch\Pipelines\Payloads;
4
5
/**
6
 * Class CreateMigrationPayload
7
 * @package Nord\Lumen\Elasticsearch\Pipelines\Payloads
8
 */
9
class CreateMigrationPayload extends MigrationPayload
10
{
11
12
    /**
13
     * @var int
14
     */
15
    protected $versionName;
16
17
    /**
18
     * IndexMigrationPayload constructor.
19
     *
20
     * @param string $configurationPath
21
     */
22
    public function __construct($configurationPath)
23
    {
24
        parent::__construct($configurationPath);
25
26
        // Determine the index name
27
        $this->versionName = time();
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getVersionPath()
34
    {
35
        return sprintf('%s/%d.php', $this->getIndexVersionsPath(), $this->getVersionName());
36
    }
37
38
    /**
39
     * @return int
40
     */
41
    public function getVersionName()
42
    {
43
        return $this->versionName;
44
    }
45
46
    public function getIndexVersionName()
47
    {
48
        return sprintf('%s_%d', $this->getIndexName(), $this->getVersionName());
49
    }
50
}
51