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

IndexConfigurationRepository::get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 5
cts 5
cp 1
rs 9.4285
cc 3
eloc 6
nc 3
nop 2
crap 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
}