EntityManagerTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
eloc 7
c 2
b 0
f 0
dl 0
loc 13
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A setUpEntityManager() 0 9 1
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