Passed
Push — master ( fdad2f...017b91 )
by Gerrit
04:01
created

AddiksRDMBundle   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 15 1
A registerClassLoader() 0 3 1
A classLoader() 0 3 1
1
<?php
2
3
namespace Addiks\RDMBundle;
4
5
use Symfony\Component\HttpKernel\Bundle\Bundle;
6
use Psr\Container\ContainerInterface;
7
use Webmozart\Assert\Assert;
8
use Addiks\RDMBundle\DataLoader\DataLoaderInterface;
9
use Doctrine\ORM\EntityManagerInterface;
10
use Composer\Autoload\ClassLoader;
11
12
class AddiksRDMBundle extends Bundle
13
{
14
    private static ClassLoader|null $classLoader = null;
15
16
    public function boot()
17
    {
18
        Assert::isInstanceOf($this->container, ContainerInterface::class);
19
20
        /** @var DataLoaderInterface $dataLoader */
21
        $dataLoader = $this->container->get('addiks_rdm.data_loader');
22
23
        Assert::isInstanceOf($dataLoader, DataLoaderInterface::class);
24
25
        /** @var EntityManagerInterface $entityManager */
26
        $entityManager = $this->container->get('doctrine.orm.entity_manager');
27
28
        Assert::isInstanceOf($entityManager, EntityManagerInterface::class);
29
30
        $dataLoader->boot($entityManager);
31
    }
32
33
    public static function classLoader(): ClassLoader|null
34
    {
35
        return self::$classLoader;
36
    }
37
38
    public static function registerClassLoader(ClassLoader $classLoader): void
39
    {
40
        self::$classLoader = $classLoader;
41
    }
42
}
43