PHPDriver::loadMappingFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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