Completed
Push — develop ( 909b54...bbea00 )
by Quang
02:17
created

IndexNamePrefixer::getPrefixedIndexParameters()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Nord\Lumen\Elasticsearch;
4
5
class IndexNamePrefixer
6
{
7
    public static function getPrefixedIndexName(string $indexName): string
8
    {
9
        $prefix = \getenv('ELASTICSEARCH_INDEX_PREFIX');
10
11
        if ($prefix) {
12
            return \sprintf('%s_%s', $prefix, $indexName);
13
        }
14
15
        return $indexName;
16
    }
17
18
    public static function getPrefixedIndexParameters(array $parameters): array
19
    {
20
        if (isset($parameters['index'])) {
21
            $parameters['index'] = self::getPrefixedIndexName($parameters['index']);
22
        }
23
24
        return $parameters;
25
    }
26
}
27