Module   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 6 1
A bootstrapEntityRepositoryManager() 0 10 1
A getConfig() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\LaminasEntity;
6
7
use Arp\LaminasEntity\Service\EntityRepositoryManager;
8
use Arp\LaminasEntity\Service\EntityRepositoryManagerProviderInterface;
9
use Laminas\ModuleManager\Listener\ServiceListenerInterface;
10
use Laminas\ModuleManager\ModuleManager;
11
use Laminas\ModuleManager\ModuleManagerInterface;
12
use Psr\Container\ContainerInterface;
13
14
/**
15
 * @author  Alex Patterson <[email protected]>
16
 * @package Arp\LaminasEntity
17
 */
18
final class Module
19
{
20
    /**
21
     * @param ModuleManagerInterface|ModuleManager $moduleManager
22
     */
23
    public function init(ModuleManagerInterface $moduleManager): void
24
    {
25
        /** @var ContainerInterface $serviceManager */
26
        $serviceManager = $moduleManager->getEvent()->getParam('ServiceManager');
0 ignored issues
show
Bug introduced by
The method getEvent() does not exist on Laminas\ModuleManager\ModuleManagerInterface. Did you maybe mean getEventManager()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $serviceManager = $moduleManager->/** @scrutinizer ignore-call */ getEvent()->getParam('ServiceManager');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
28
        $this->bootstrapEntityRepositoryManager($serviceManager);
29
    }
30
31
    /**
32
     * Prepare the entity repository manager.
33
     *
34
     * @param ContainerInterface $container
35
     */
36
    private function bootstrapEntityRepositoryManager(ContainerInterface $container): void
37
    {
38
        /** @var ServiceListenerInterface $serviceListener */
39
        $serviceListener = $container->get('ServiceListener');
40
41
        $serviceListener->addServiceManager(
42
            EntityRepositoryManager::class,
43
            'entity_repository_manager',
44
            EntityRepositoryManagerProviderInterface::class,
45
            'getEntityRepositoryConfig'
46
        );
47
    }
48
49
    /**
50
     * @return array
51
     */
52
    public function getConfig(): array
53
    {
54
        return require __DIR__ . '/../config/module.config.php';
55
    }
56
}
57