EntityManagerTrait::setUpEntityManager()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLTests\Doctrine;
6
7
use Doctrine\DBAL\DriverManager;
8
use Doctrine\ORM\EntityManager;
9
use Doctrine\ORM\ORMSetup;
10
11
/**
12
 * Trait to easily set up a dummy entity manager.
13
 */
14
trait EntityManagerTrait
15
{
16
    private EntityManager $entityManager;
17
18
    private function setUpEntityManager(): void
19
    {
20
        $config = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/Blog/Model'], true);
21
        $connection = DriverManager::getConnection([
22
            'driver' => 'sqlite3',
23
            'memory' => true,
24
        ]);
25
26
        $this->entityManager = new EntityManager($connection, $config);
27
    }
28
}
29