PHPDriver   A
last analyzed

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 8
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
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