TransactionManager::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Common\Doctrine\Orm;
6
7
use Closure;
8
use Damax\Common\Domain\Transaction\TransactionManager as TransactionManagerInterface;
9
use Doctrine\ORM\EntityManagerInterface;
10
11
final class TransactionManager implements TransactionManagerInterface
12
{
13
    private $em;
14
15
    public function __construct(EntityManagerInterface $em)
16
    {
17
        $this->em = $em;
18
    }
19
20
    public function begin(): void
21
    {
22
        $this->em->beginTransaction();
23
    }
24
25
    public function commit(): void
26
    {
27
        $this->em->commit();
28
    }
29
30
    public function rollback(): void
31
    {
32
        $this->em->rollback();
33
    }
34
35
    public function run(Closure $fn): void
36
    {
37
        $this->em->transactional($fn);
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\ORM\EntityManag...erface::transactional() has been deprecated: 2.10 Use {@link wrapInTransaction} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

37
        /** @scrutinizer ignore-deprecated */ $this->em->transactional($fn);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
38
    }
39
}
40