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

IndexTemplateConfig::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
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