Passed
Pull Request — master (#129)
by Serhii
18:29 queued 11:06
created

Get   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 36
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A anyIndex() 0 3 1
A toArray() 0 5 1
1
<?php
2
3
namespace Matchish\ScoutElasticSearch\ElasticSearch\Params\Indices\Alias;
4
5
/**
6
 * @internal
7
 */
8
final class Get
9
{
10
    /**
11
     * @var string
12
     */
13
    private $alias;
14
    /**
15
     * @var string
16
     */
17
    private $index;
18
19
    /**
20
     * Get constructor.
21
     * @param string $alias
22
     * @param string $index
23
     */
24 15
    public function __construct(string $alias, string $index = '*')
25
    {
26 15
        $this->alias = $alias;
27 15
        $this->index = $index;
28 15
    }
29
30
    /**
31
     * @return array
32
     */
33 15
    public function toArray()
34
    {
35
        return [
36 15
            'index' => $this->index,
37 15
            'name' => $this->alias,
38
        ];
39
    }
40
41 15
    public static function anyIndex(string $alias): Get
42
    {
43 15
        return new static($alias, '*');
44
    }
45
}
46