Completed
Push — master ( 8b30ba...c06433 )
by Karel
04:39
created

IndexTemplateConfig   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 42
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 2
A getTemplate() 0 4 1
1
<?php
2
3
namespace FOS\ElasticaBundle\Configuration;
4
5
/**
6
 * Index template configuration class
7
 *
8
 * @author Dmitry Balabka <[email protected]>
9
 */
10
class IndexTemplateConfig implements IndexConfigInterface
11
{
12
    use IndexConfigTrait;
13
14
    /**
15
     * Index name pattern
16
     *
17
     * @var string
18
     */
19
    private $template;
20
21
    /**
22
     * Constructor expects an array as generated by the Container Configuration builder.
23
     *
24
     * @param string       $name
25
     * @param TypeConfig[] $types
26
     * @param array        $config
27
     */
28 9
    public function __construct($name, array $types, array $config)
29
    {
30 9
        $this->elasticSearchName = $config['elasticSearchName'] ?? $name;
31 9
        $this->name = $name;
32 9
        $this->settings = $config['settings'] ?? array();
33
34 9
        if (!isset($config['template'])) {
35 1
            throw new \InvalidArgumentException('Index template value must be set');
36
        }
37
38 8
        $this->template = $config['template'];
39 8
        $this->types = $types;
40 8
    }
41
42
    /**
43
     * Gets index name pattern
44
     *
45
     * @return string
46
     */
47 7
    public function getTemplate()
48
    {
49 7
        return $this->template;
50
    }
51
}
52