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

TransactionManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 11
c 4
b 0
f 0
dl 0
loc 48
rs 10
wmc 5

5 Methods

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