Completed
Pull Request — 1.3.x (#71)
by Grégoire
06:05
created

PHPDriver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 32
ccs 11
cts 11
cp 1
rs 10

3 Methods

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