Test Failed
Push — dev ( 6bf3a3...95bf36 )
by Janko
09:38
created

EntityManagerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createEntityManager() 0 5 1
1
<?php
2
3
namespace Stu\Orm\Transaction;
4
5
use Doctrine\DBAL\Connection;
6
use Doctrine\ORM\Configuration;
7
use Doctrine\ORM\EntityManager;
8
use Doctrine\ORM\EntityManagerInterface;
9
10
class EntityManagerFactory implements EntityManagerFactoryInterface
11
{
12
    public function __construct(
13
        private ConnectionFactoryInterface $connectionFactory,
14
        private Configuration $configuration
15
    ) {}
16
17
    public function createEntityManager(Connection $connection = null): EntityManagerInterface
18
    {
19
        return new EntityManager(
20
            $connection ?? $this->connectionFactory->createConnection(),
21
            $this->configuration
22
        );
23
    }
24
}
25