Failed Conditions
Push — master ( 3a6c46...2fbe69 )
by Luís
36s queued 11s
created

PHPDriver::loadMetadataForClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Doctrine\Persistence\Mapping\Driver;
4
5
use Doctrine\Persistence\Mapping\ClassMetadata;
6
7
/**
8
 * The PHPDriver includes php files which just populate ClassMetadataInfo
9
 * instances with plain PHP code.
10
 */
11
class PHPDriver extends FileDriver
12
{
13
    /** @var ClassMetadata */
14
    protected $metadata;
15
16
    /**
17
     * {@inheritDoc}
18
     */
19 1
    public function __construct($locator)
20
    {
21 1
        parent::__construct($locator, '.php');
22 1
    }
23
24
    /**
25
     * {@inheritDoc}
26
     */
27 1
    public function loadMetadataForClass($className, ClassMetadata $metadata)
28
    {
29 1
        $this->metadata = $metadata;
30
31 1
        $this->loadMappingFile($this->locator->findMappingFile($className));
32 1
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37 1
    protected function loadMappingFile($file)
38
    {
39 1
        $metadata = $this->metadata;
40 1
        include $file;
41
42 1
        return [$metadata->getName() => $metadata];
43
    }
44
}
45