Completed
Pull Request — master (#1343)
by Dmitry
08:46
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 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 View Code Duplication
    public function __construct($name, array $types, array $config)
29
    {
30
        $this->elasticSearchName = isset($config['elasticSearchName']) ? $config['elasticSearchName'] : $name;
31
        $this->name = $name;
32
        $this->settings = isset($config['settings']) ? $config['settings'] : array();
33
        if (!isset($config['template'])) {
34
            throw new \InvalidArgumentException('Index template value must be set');
35
        }
36
        $this->template = $config['template'];
37
        $this->types = $types;
38
    }
39
40
    /**
41
     * Gets index name pattern
42
     *
43
     * @return string
44
     */
45
    public function getTemplate()
46
    {
47
        return $this->template;
48
    }
49
}
50