Passed
Push — dev ( eeaa0f...91a85a )
by Janko
26:10
created

EntityManagerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createEntityManager() 0 5 1
A __construct() 0 4 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 4
    public function __construct(
13
        private ConnectionFactoryInterface $connectionFactory,
14
        private Configuration $configuration
15
    ) {
16 4
    }
17
18 4
    public function createEntityManager(Connection $connection = null): EntityManagerInterface
19
    {
20 4
        return new EntityManager(
21 4
            $connection ?? $this->connectionFactory->createConnection(),
22 4
            $this->configuration
23 4
        );
24
    }
25
}
26