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

PHPDriver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 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