Passed
Pull Request — master (#129)
by Serhii
09:00
created

Update::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Matchish\ScoutElasticSearch\ElasticSearch\Params\Indices\Alias;
4
5
/**
6
 * @internal
7
 */
8
final class Update
9
{
10
    /**
11
     * @var array
12
     */
13
    private $actions = [];
14
15
    /**
16
     * @param array $actions
17
     */
18 14
    public function __construct(array $actions = [])
19
    {
20 14
        $this->actions = $actions;
21 14
    }
22
23
    /**
24
     * @return array
25
     */
26 14
    public function toArray(): array
27
    {
28
        return [
29
            'body' => [
30 14
                'actions' => $this->actions,
31
            ],
32
        ];
33
    }
34
35 14
    public function add(string $index, string $alias): void
36
    {
37 14
        $this->actions[] = ['add' => [
38 14
            'index' => $index,
39 14
            'alias' => $alias,
40
        ]];
41 14
    }
42
43 2
    public function removeIndex(string $index): void
44
    {
45 2
        $this->actions[] = ['remove_index' => ['index' => $index]];
46 2
    }
47
}
48