EntityRepositoryManagerFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Pgs\ElasticOM\Bridge\ZF3;
4
5
use Pgs\ElasticOM\AdapterFactory;
6
use Pgs\ElasticOM\EntityRepositoryManager;
7
use Zend\ServiceManager\ServiceManager;
8
9
class EntityRepositoryManagerFactory
10
{
11 1
    public function __invoke(ServiceManager $sm)
12
    {
13 1
        $config = $sm->get('Config');
14
15 1
        $adapter = AdapterFactory::create(
16 1
            $config[Module::CONFIG_KEY]['host'] ?? 'localhost',
17 1
            $config[Module::CONFIG_KEY]['port'] ?? 9200,
18 1
            $config[Module::CONFIG_KEY]['index'] ?? 'elastic_om'
19
        );
20
21 1
        return new EntityRepositoryManager($adapter);
22
    }
23
}
24