Completed
Push — master ( 3d2cfc...12b419 )
by Alejandro
14s queued 12s
created

EnhancedPHPDriver::loadMappingFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\Common\Doctrine\Mapping;
6
7
use Doctrine\Persistence\Mapping\Driver\PHPDriver;
8
9
class EnhancedPHPDriver extends PHPDriver
10
{
11
    private array $emConfig;
12
    private bool $loadMappingsUsingFunctionalStyle;
13
14 8
    public function __construct($locator, array $emConfig, bool $loadMappingsUsingFunctionalStyle = false) // phpcs:ignore
15
    {
16 8
        parent::__construct($locator);
17 8
        $this->emConfig = $emConfig;
18 8
        $this->loadMappingsUsingFunctionalStyle = $loadMappingsUsingFunctionalStyle;
19
    }
20
21 3
    protected function loadMappingFile($file): array // phpcs:ignore
22
    {
23 3
        $metadata = $this->metadata;
24 3
        $emConfig = $this->emConfig;
25
26 3
        if ($this->loadMappingsUsingFunctionalStyle) {
27 1
            (include $file)($metadata, $emConfig);
28
        } else {
29 2
            include $file;
30
        }
31
32 3
        return [$metadata->getName() => $metadata];
33
    }
34
}
35