Completed
Push — 1.1 ( d166b0...e7f438 )
by Patrick
11:31 queued 07:46
created

ExtensibleClassMetadataFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 1
cbo 4
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setEntityManager() 0 6 1
A newClassMetadataInstance() 0 4 1
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Extensions;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
use Doctrine\ORM\Mapping\ClassMetadataFactory;
7
8
class ExtensibleClassMetadataFactory extends ClassMetadataFactory
9
{
10
    /**
11
     * @var EntityManagerInterface
12
     */
13
    protected $entityManager;
14
15
    /**
16
     * Override to hold a reference to the EntityManager here as well (parent property is private).
17
     *
18
     * {@inheritdoc}
19
     */
20
    public function setEntityManager(EntityManagerInterface $em)
21
    {
22
        parent::setEntityManager($em);
23
24
        $this->entityManager = $em;
25
    }
26
27
    /**
28
     * Override to implement our custom ClassMetadata object.
29
     *
30
     * {@inheritdoc}
31
     */
32
    protected function newClassMetadataInstance($className)
33
    {
34
        return new ExtensibleClassMetadata($className, $this->entityManager->getConfiguration()->getNamingStrategy());
35
    }
36
}
37