Completed
Push — master ( 57a48c...37b82a )
by Alejandro
14s queued 13s
created

ReopeningEntityManager::remove()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\Common\Doctrine;
6
7
use Doctrine\ORM\Decorator\EntityManagerDecorator;
8
9
class ReopeningEntityManager extends EntityManagerDecorator
10
{
11
    /** @var callable */
12
    private $createEm;
13
14 3
    public function __construct(callable $createEm)
15
    {
16 3
        parent::__construct($createEm());
17 3
        $this->createEm = $createEm;
18
    }
19
20 2
    public function open(): void
21
    {
22 2
        if (! $this->wrapped->isOpen()) {
23 1
            $this->wrapped = ($this->createEm)();
24
        }
25
    }
26
}
27