MappingPHPDriverFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 17
ccs 6
cts 6
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A createRDMMappingDriver() 0 14 2
1
<?php
2
/**
3
 * Copyright (C) 2018 Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 * @license GPL-3.0
8
 * @author Gerrit Addiks <[email protected]>
9
 */
10
11
namespace Addiks\RDMBundle\Mapping\DriverFactories;
12
13
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
14
use Doctrine\Persistence\Mapping\Driver\PHPDriver;
15
use Doctrine\Persistence\Mapping\Driver\FileLocator;
16
use Addiks\RDMBundle\Mapping\DriverFactories\MappingDriverFactoryInterface;
17
use Addiks\RDMBundle\Mapping\Drivers\MappingDriverInterface;
18
use Addiks\RDMBundle\Mapping\Drivers\MappingPHPDriver;
19
20
final class MappingPHPDriverFactory implements MappingDriverFactoryInterface
21
{
22
23 1
    public function createRDMMappingDriver(
24
        MappingDriver $mappingDriver
25
    ): ?MappingDriverInterface {
26
        /** @var ?MappingDriverInterface $rdmMetadataDriver */
27 1
        $rdmMetadataDriver = null;
28
29 1
        if ($mappingDriver instanceof PHPDriver) {
30
            /** @var FileLocator $fileLocator */
31 1
            $fileLocator = $mappingDriver->getLocator();
32
33 1
            $rdmMetadataDriver = new MappingPHPDriver($fileLocator);
34
        }
35
36 1
        return $rdmMetadataDriver;
37
    }
38
39
}
40