Passed
Push — master ( ad0a32...6741d2 )
by Dāvis
05:00
created

InsertFunctions   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 42
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getObject() 0 3 1
A setObject() 0 4 1
A setManager() 0 6 2
1
<?php
2
3
namespace Sludio\HelperBundle\Script\Repository;
4
5
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
6
7
class InsertFunctions
8
{
9
    protected $connection;
10
11
    protected $object;
12
13
    /**
14
     * @var ClassMetadata
15
     */
16
    protected $metadata;
17
18
    public $doctrine;
19
20
    public $entityManager;
21
22
    public function __construct($doctrine, $defaultManager)
23
    {
24
        $this->doctrine = $doctrine;
25
        $this->connection = $this->doctrine->getManager('default')->getConnection();
26
        $this->setManager($defaultManager);
27
    }
28
29
    public function getObject()
30
    {
31
        return $this->object;
32
    }
33
34
    /**
35
     * @param object $object
36
     */
37
    public function setObject($object)
38
    {
39
        $this->object = $object;
40
        $this->metadata = $this->entityManager->getMetadataFactory()->getMetadataFor(\get_class($object));
41
    }
42
43
    public function setManager($manager)
44
    {
45
        if (\is_object($manager)) {
46
            $this->entityManager = $manager;
47
        } else {
48
            $this->entityManager = $this->doctrine->getManager($manager);
49
        }
50
    }
51
}
52