Completed
Push — master ( a36c27...010ee5 )
by GBProd
02:47
created

IndexConfigurationRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 36
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 12 3
1
<?php
2
3
namespace GBProd\ElasticsearchExtraBundle\Repository;
4
5
/**
6
 * Repository for index configuration
7
 * 
8
 * @author gbprod <[email protected]>
9
 */
10
class IndexConfigurationRepository
11
{
12
    /**
13
     * @var array
14
     */
15
    private $config;
16
    
17
    /**
18
     * @param array $config
19
     */
20
    public function __construct(array $config = array())
21
    {
22 1
        $this->config = $config;
23 1
    }
24
    
25
    /**
26
     * Get client from his name
27
     * 
28
     * @param string $clientId
29
     * @param string $indexId
30
     * 
31
     * @return Elasticsearch\Client
32
     */
33
    public function get($clientId, $indexId)
34
    {
35 1
        if (!isset($this->config[$clientId])) {
36 1
            return null;
37
        }
38
        
39 1
        if (!isset($this->config[$clientId]['indices'][$indexId])) {
40 1
            return null;
41
        }
42
43 1
        return $this->config[$clientId]['indices'][$indexId];
44
    }
45
}