Failed Conditions
Pull Request — master (#1)
by Jonathan
13:20 queued 01:26
created

PHPDriver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A loadMappingFile() 0 6 1
A __construct() 0 3 1
A loadMetadataForClass() 0 5 1
1
<?php
2
namespace Doctrine\Common\Persistence\Mapping\Driver;
3
4
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
5
6
/**
7
 * The PHPDriver includes php files which just populate ClassMetadataInfo
8
 * instances with plain PHP code.
9
 *
10
 * @link   www.doctrine-project.org
11
 * @since  2.0
12
 * @author Benjamin Eberlei <[email protected]>
13
 * @author Guilherme Blanco <[email protected]>
14
 * @author Jonathan H. Wage <[email protected]>
15
 * @author Roman Borschel <[email protected]>
16
 */
17
class PHPDriver extends FileDriver
18
{
19
    /**
20
     * @var ClassMetadata
21
     */
22
    protected $metadata;
23
24
    /**
25
     * {@inheritDoc}
26
     */
27
    public function __construct($locator)
28
    {
29
        parent::__construct($locator, '.php');
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    public function loadMetadataForClass($className, ClassMetadata $metadata)
36
    {
37
        $this->metadata = $metadata;
38
39
        $this->loadMappingFile($this->locator->findMappingFile($className));
40
    }
41
42
    /**
43
     * {@inheritDoc}
44
     */
45
    protected function loadMappingFile($file)
46
    {
47
        $metadata = $this->metadata;
48
        include $file;
49
50
        return [$metadata->getName() => $metadata];
51
    }
52
}
53