Completed
Pull Request — master (#1343)
by Dmitry
05:26
created

IndexTemplateConfig::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 4
nc 8
nop 3
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 extends IndexConfigAbstract
11
{
12
    /**
13
     * Index name pattern
14
     *
15
     * @var string
16
     */
17
    private $template;
18
19
    /**
20
     * Constructor expects an array as generated by the Container Configuration builder.
21
     *
22
     * @param string       $name
23
     * @param TypeConfig[] $types
24
     * @param array        $config
25
     */
26 View Code Duplication
    public function __construct($name, array $types, array $config)
27
    {
28
        $this->elasticSearchName = isset($config['elasticSearchName']) ? $config['elasticSearchName'] : $name;
29
        $this->name = $name;
30
        $this->settings = isset($config['settings']) ? $config['settings'] : array();
31
        if (!isset($config['template'])) {
32
            throw new \InvalidArgumentException('Index template value must be set');
33
        }
34
        $this->template = $config['template'];
35
        $this->types = $types;
36
    }
37
38
    /**
39
     * Gets index name pattern
40
     *
41
     * @return string
42
     */
43
    public function getTemplate()
44
    {
45
        return $this->template;
46
    }
47
}
48