Failed Conditions
Pull Request — master (#1)
by Jonathan
03:48
created

PHPDriver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 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 1
    public function __construct($locator)
28
    {
29 1
        parent::__construct($locator, '.php');
30 1
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35 1
    public function loadMetadataForClass($className, ClassMetadata $metadata)
36
    {
37 1
        $this->metadata = $metadata;
38
39 1
        $this->loadMappingFile($this->locator->findMappingFile($className));
40 1
    }
41
42
    /**
43
     * {@inheritDoc}
44
     */
45 1
    protected function loadMappingFile($file)
46
    {
47 1
        $metadata = $this->metadata;
48 1
        include $file;
49
50 1
        return [$metadata->getName() => $metadata];
51
    }
52
}
53