Passed
Push — master ( f6c88e...b9c768 )
by Dāvis
03:50
created

InsertFunctions::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\Script\Repository;
4
5
use Sludio\HelperBundle\Script\Utils\Helper;
6
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
7
8
class InsertFunctions
9
{
10
    protected $connection;
11
12
    /**
13
     * @var \stdClass
14
     */
15
    protected $object;
16
17
    /**
18
     * @var ClassMetadata
19
     */
20
    protected $metadata;
21
22
    public $entityManager;
23
24
    public function __construct($entityManager, \stdClass $object = null)
25
    {
26
        $this->entityManager = $entityManager;
27
        $this->connection = $this->entityManager->getConnection();
28
        $this->setObject($object);
0 ignored issues
show
Bug introduced by
It seems like $object can also be of type stdClass; however, parameter $object of Sludio\HelperBundle\Scri...tFunctions::setObject() does only seem to accept null, maybe add an additional type check? ( Ignorable by Annotation )

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

28
        $this->setObject(/** @scrutinizer ignore-type */ $object);
Loading history...
29
    }
30
31
    /**
32
     * @return null
33
     */
34
    public function getObject()
35
    {
36
        return $this->object;
37
    }
38
39
    /**
40
     * @param null $object
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $object is correct as it would always require null to be passed?
Loading history...
41
     *
42
     * @return InsertFunctions
43
     */
44
    public function setObject($object)
45
    {
46
        $this->object = $object;
47
        if ($object !== null) {
48
            $this->metadata = $this->entityManager->getMetadataFactory()->getMetadataFor(get_class($object));
49
        }
50
51
        return $this;
52
    }
53
}