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

Fake   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 9
rs 10
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