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.

PopulatorManager   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 5
dl 0
loc 63
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A registerFetcher() 0 8 2
A getFetcherForType() 0 11 2
A createPopulator() 0 8 1
1
<?php
2
3
namespace Nimble\ElasticBundle\Populator;
4
5
use Nimble\ElasticBundle\Populator\Exception\PopulationFetcherAlreadyRegisteredException;
6
use Nimble\ElasticBundle\Populator\Exception\PopulationFetcherNotFoundException;
7
use Nimble\ElasticBundle\Transformer\TransformerManager;
8
use Nimble\ElasticBundle\Type\Type;
9
10
class PopulatorManager
11
{
12
    /**
13
     * @var PopulationFetcherInterface[][]
14
     */
15
    protected $fetchers = [];
16
17
    /**
18
     * @var TransformerManager
19
     */
20
    private $transformer;
21
22
    /**
23
     * @param TransformerManager $transformer
24
     */
25
    public function __construct(TransformerManager $transformer)
26
    {
27
        $this->transformer = $transformer;
28
    }
29
30
    /**
31
     * @param $indexId
32
     * @param $typeName
33
     * @param PopulationFetcherInterface $fetcher
34
     */
35
    public function registerFetcher(PopulationFetcherInterface $fetcher, $indexId, $typeName)
36
    {
37
        if (isset($this->fetchers[$indexId][$typeName])) {
38
            throw new PopulationFetcherAlreadyRegisteredException($indexId, $typeName);
39
        }
40
41
        $this->fetchers[$indexId][$typeName] = $fetcher;
42
    }
43
44
    /**
45
     * @param Type $type
46
     * @return PopulationFetcherInterface
47
     */
48
    protected function getFetcherForType(Type $type)
49
    {
50
        $indexId = $type->getIndex()->getId();
51
        $typeName = $type->getName();
52
53
        if (!isset($this->fetchers[$indexId][$typeName])) {
54
            throw new PopulationFetcherNotFoundException($indexId, $typeName);
55
        }
56
57
        return $this->fetchers[$indexId][$typeName];
58
    }
59
60
    /**
61
     * @param Type $type
62
     * @return Populator
63
     */
64
    public function createPopulator(Type $type)
65
    {
66
        return new Populator(
67
            $type,
68
            $this->getFetcherForType($type),
69
            $this->transformer
70
        );
71
    }
72
}