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

Fake::foo()   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\Injector;
6
use Ray\DoctrineOrmModule\DoctrineOrmModule;
7
use Ray\DoctrineOrmModule\Inject\EntityManagerInject;
8
9
$loader = require dirname(dirname(__DIR__)) . '/vendor/autoload.php';
10
/* @var $loader \Composer\Autoload\ClassLoader */
11
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
12
13
class Fake
14
{
15
    use EntityManagerInject;
16
17
    public function foo()
18
    {
19
        return $this->entityManager;
20
    }
21
}
22
23
/* @var $fake Fake */
24
$fake = (new Injector(new DoctrineOrmModule(['driver' => 'pdo_sqlite', 'memory' => true], ['/path/to/entity/'])))->getInstance(Fake::class);
25
26
$works = ($fake->foo() instanceof EntityManagerInterface);
27
echo($works ? 'It works!' : 'It DOES NOT work!') . PHP_EOL;
28