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

AppModule::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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