Completed
Push — master ( a83c68...48e6dd )
by Yuu
02:36
created

AppModule   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 7
rs 10
1
<?php
2
3
use Doctrine\Common\Annotations\AnnotationRegistry;
4
use Doctrine\ORM\EntityManagerInterface;
5
use Ray\Di\AbstractModule;
6
use Ray\Di\Injector;
7
use Ray\DoctrineOrmModule\DoctrineOrmModule;
8
use Ray\DoctrineOrmModule\Inject\EntityManagerInject;
9
10
$loader = require dirname(dirname(__DIR__)) . '/vendor/autoload.php';
11
/* @var $loader \Composer\Autoload\ClassLoader */
12
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
13
14
class Fake
15
{
16
    use EntityManagerInject;
17
18
    public function foo()
19
    {
20
        return $this->entityManager;
21
    }
22
}
23
24
class AppModule extends AbstractModule
25
{
26
    protected function configure()
27
    {
28
        $this->install(new DoctrineOrmModule(['driver' => 'pdo_sqlite', 'memory' => true], ['/path/to/entity/']));
29
    }
30
}
31
32
/* @var $fake Fake */
33
$fake = (new Injector(new AppModule))->getInstance(Fake::class);
34
35
$works = ($fake->foo() instanceof EntityManagerInterface);
36
echo($works ? 'It works!' : 'It DOES NOT work!') . PHP_EOL;
37