Completed
Push — develop ( bdcd74...c796db )
by Sam
13s
created

ApplyMigrationPayload   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
dl 0
loc 85
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getTargetVersionPath() 0 3 1
A getNumberOfReplicas() 0 3 1
A setTargetVersionFile() 0 3 1
A __construct() 0 5 1
A getBatchSize() 0 3 1
A getTargetConfiguration() 0 3 1
A setNumberOfReplicas() 0 3 1
A getTargetVersionName() 0 3 1
1
<?php
2
3
namespace Nord\Lumen\Elasticsearch\Pipelines\Payloads;
4
5
/**
6
 * Class ApplyMigrationPayload
7
 * @package Nord\Lumen\Elasticsearch\Pipelines\Payloads
8
 */
9
class ApplyMigrationPayload extends MigrationPayload
10
{
11
12
    /**
13
     * @var string
14
     */
15
    private $targetVersionFile;
16
17
    /**
18
     * @var int
19
     */
20
    private $batchSize;
21
22
    /**
23
     * @var int
24
     */
25
    private $numberOfReplicas;
26
27
    /**
28
     * ApplyMigrationPayload constructor.
29
     *
30
     * @param string $configurationPath
31
     * @param int    $batchSize
32
     */
33
    public function __construct($configurationPath, $batchSize)
34
    {
35
        parent::__construct($configurationPath);
36
37
        $this->batchSize = $batchSize;
38
    }
39
40
    /**
41
     * @param string $targetVersionFile
42
     */
43
    public function setTargetVersionFile($targetVersionFile)
44
    {
45
        $this->targetVersionFile = $targetVersionFile;
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getTargetVersionPath()
52
    {
53
        return sprintf('%s/%s', $this->getIndexVersionsPath(), $this->targetVersionFile);
54
    }
55
56
    /**
57
     * @return array
58
     */
59
    public function getTargetConfiguration()
60
    {
61
        return include $this->getTargetVersionPath();
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function getTargetVersionName()
68
    {
69
        return $this->getTargetConfiguration()['index'];
70
    }
71
72
    /**
73
     * @return int
74
     */
75
    public function getBatchSize()
76
    {
77
        return $this->batchSize;
78
    }
79
80
    /**
81
     * @return int
82
     */
83
    public function getNumberOfReplicas()
84
    {
85
        return $this->numberOfReplicas;
86
    }
87
88
    /**
89
     * @param int $numberOfReplicas
90
     */
91
    public function setNumberOfReplicas($numberOfReplicas)
92
    {
93
        $this->numberOfReplicas = $numberOfReplicas;
94
    }
95
}
96