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

IndexConfigTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 79
ccs 11
cts 12
cp 0.9167
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getElasticSearchName() 0 4 1
A getName() 0 4 1
A getSettings() 0 4 1
A getType() 0 8 2
A getTypes() 0 4 1
1
<?php
2
/*
3
 * This file is part of the OpCart software.
4
 *
5
 * (c) 2015, OpticsPlanet, Inc
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace FOS\ElasticaBundle\Configuration;
12
13
/**
14
 * Index configuration trait class
15
 *
16
 * @author Dmitry Balabka <[email protected]>
17
 */
18
trait IndexConfigTrait
19
{
20
    /**
21
     * The name of the index for ElasticSearch.
22
     *
23
     * @var string
24
     */
25
    private $elasticSearchName;
26
27
    /**
28
     * The internal name of the index. May not be the same as the name used in ElasticSearch,
29
     * especially if aliases are enabled.
30
     *
31
     * @var string
32
     */
33
    private $name;
34
35
    /**
36
     * An array of settings sent to ElasticSearch when creating the index.
37
     *
38
     * @var array
39
     */
40
    private $settings;
41
42
    /**
43
     * All types that belong to this index.
44
     *
45
     * @var TypeConfig[]
46
     */
47
    private $types;
48
49
    /**
50
     * @return string
51
     */
52 11
    public function getElasticSearchName()
53
    {
54 11
        return $this->elasticSearchName;
55
    }
56
57
    /**
58
     * @return string
59
     */
60 3
    public function getName()
61
    {
62 3
        return $this->name;
63
    }
64
65
    /**
66
     * @return array
67
     */
68 12
    public function getSettings()
69
    {
70 12
        return $this->settings;
71
    }
72
73
    /**
74
     * @param string $typeName
75
     *
76
     * @return TypeConfig
77
     *
78
     * @throws \InvalidArgumentException
79
     */
80 4
    public function getType($typeName)
81
    {
82 4
        if (!array_key_exists($typeName, $this->types)) {
83
            throw new \InvalidArgumentException(sprintf('Type "%s" does not exist on index "%s"', $typeName, $this->name));
84
        }
85
86 4
        return $this->types[$typeName];
87
    }
88
89
    /**
90
     * @return \FOS\ElasticaBundle\Configuration\TypeConfig[]
91
     */
92 11
    public function getTypes()
93
    {
94 11
        return $this->types;
95
    }
96
}
97