Passed
Pull Request — master (#188)
by Damien
02:36
created

TransactionManager::populate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace DH\DoctrineAuditBundle\Transaction;
4
5
use DH\DoctrineAuditBundle\Configuration;
6
use DH\DoctrineAuditBundle\Model\Transaction;
7
use Doctrine\ORM\EntityManagerInterface;
8
9
class TransactionManager
10
{
11
    /**
12
     * @var Configuration
13
     */
14
    private $configuration;
15
16
    /**
17
     * @var TransactionProcessor
18
     */
19
    private $processor;
20
21
    /**
22
     * @var TransactionHydrator
23
     */
24
    private $hydrator;
25
26
    public function __construct(Configuration $configuration)
27
    {
28
        $this->configuration = $configuration;
29
30
        $this->processor = new TransactionProcessor($configuration);
31
        $this->hydrator = new TransactionHydrator($configuration);
32
    }
33
34
    public function getConfiguration(): Configuration
35
    {
36
        return $this->configuration;
37
    }
38
39
    public function populate(Transaction $transaction): void
40
    {
41
        $this->hydrator->hydrate($transaction);
42
    }
43
44
    public function process(Transaction $transaction): void
45
    {
46
        $this->processor->process($transaction);
47
    }
48
49
    /**
50
     * @param EntityManagerInterface $em
51
     *
52
     * @return EntityManagerInterface
53
     */
54
    public function selectStorageSpace(EntityManagerInterface $em): EntityManagerInterface
55
    {
56
        return $this->configuration->getEntityManager() ?? $em;
57
    }
58
}
59