GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

IndexManager   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 59
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A registerIndex() 0 10 2
A getIndex() 0 8 2
A hasIndex() 0 4 1
A getIndexIds() 0 4 1
A getIndexes() 0 4 1
1
<?php
2
3
namespace Nimble\ElasticBundle\Index;
4
5
use Nimble\ElasticBundle\Exception\IndexNotFoundException;
6
7
class IndexManager
8
{
9
    /**
10
     * @var Index[]
11
     */
12
    protected $indexes = [];
13
14
    /**
15
     * @param Index $index
16
     */
17
    public function registerIndex(Index $index)
18
    {
19
        if (array_key_exists($index->getId(), $this->indexes)) {
20
            throw new \InvalidArgumentException(
21
                sprintf('Index "%s" is already registered.', $index->getId())
22
            );
23
        }
24
25
        $this->indexes[$index->getId()] = $index;
26
    }
27
28
    /**
29
     * @param string $name
30
     * @return Index|null
31
     */
32
    public function getIndex($name)
33
    {
34
        if (!$this->hasIndex($name)) {
35
            throw new IndexNotFoundException($name);
36
        }
37
38
        return $this->indexes[$name];
39
    }
40
41
    /**
42
     * @param string $name
43
     * @return bool
44
     */
45
    public function hasIndex($name)
46
    {
47
        return array_key_exists($name, $this->indexes);
48
    }
49
50
    /**
51
     * @return array
52
     */
53
    public function getIndexIds()
54
    {
55
        return array_keys($this->indexes);
56
    }
57
58
    /**
59
     * @return Index[]
60
     */
61
    public function getIndexes()
62
    {
63
        return array_values($this->indexes);
64
    }
65
}
66