Completed
Pull Request — master (#22)
by Sergey
12:32
created

ElasticsearchCollectionParser::getIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Isswp101\Persimmon\CollectionParser;
4
5
use Isswp101\Persimmon\Exceptions\IllegalCollectionException;
6
7
class ElasticsearchCollectionParser
8
{
9
    private $index;
10
    private $type;
11
12
    public function __construct(string $collection)
13
    {
14
        $keys = explode('/', $collection);
15
        $this->index = $keys[0] ?? null;
16
        $this->type = $keys[1] ?? null;
17
        if ($this->index == null || $this->type == null) {
18
            throw new IllegalCollectionException();
19
        }
20
    }
21
22
    public function getIndex(): string
23
    {
24
        return $this->index;
25
    }
26
27
    public function getType(): string
28
    {
29
        return $this->type;
30
    }
31
}