Passed
Push — feature/initial-implementation ( 88960a...869acf )
by Fike
02:03
created

Framework::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace AmaTeam\ElasticSearch;
4
5
use AmaTeam\ElasticSearch\API\Entity\ProviderInterface;
6
use AmaTeam\ElasticSearch\API\Framework\ConfigurationInterface;
7
use AmaTeam\ElasticSearch\API\FrameworkInterface;
8
use AmaTeam\ElasticSearch\API\Mapping\ManagerInterface as MappingManagerInterface;
9
use AmaTeam\ElasticSearch\Entity\Mapping\EntityProviderWrapperMappingProvider;
10
use AmaTeam\ElasticSearch\Entity\Provider;
11
use AmaTeam\ElasticSearch\Mapping\Manager;
12
13
class Framework implements FrameworkInterface
14
{
15
    /**
16
     * @var ConfigurationInterface
17
     */
18
    private $configuration;
19
    /**
20
     * @var ProviderInterface
21
     */
22
    private $provider;
23
24
    /**
25
     * @param ConfigurationInterface $configuration
26
     */
27
    public function __construct(ConfigurationInterface $configuration)
28
    {
29
        $this->configuration = $configuration;
30
        $this->provider = new Provider();
31
        foreach ($this->configuration->getLoaders() as $loader) {
32
            $this->provider->registerLoader($loader);
33
        }
34
    }
35
36
    public function getMappingManager(): MappingManagerInterface
37
    {
38
        $mappingProvider = new EntityProviderWrapperMappingProvider($this->provider);
39
        return new Manager($mappingProvider);
40
    }
41
}
42