Completed
Pull Request — master (#917)
by Dmitry
08:52
created

IndexTemplateConfig::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 11
Code Lines 8

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 11
loc 11
ccs 9
cts 9
cp 1
rs 9.2
cc 4
eloc 8
nc 8
nop 3
crap 4
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 6 View Code Duplication
    public function __construct($name, array $types, array $config)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28 6
        $this->elasticSearchName = isset($config['elasticSearchName']) ? $config['elasticSearchName'] : $name;
29 6
        $this->name = $name;
30 6
        $this->settings = isset($config['settings']) ? $config['settings'] : array();
31 6
        if (!isset($config['template'])) {
32 1
            throw new \InvalidArgumentException('Index template value must be set');
33
        }
34 5
        $this->template = $config['template'];
35 5
        $this->types = $types;
36 5
    }
37
38
    /**
39
     * Gets index name pattern
40
     *
41
     * @return string
42
     */
43 3
    public function getTemplate()
44
    {
45 3
        return $this->template;
46
    }
47
}
48