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

EnhancedPHPDriver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 24
ccs 11
cts 11
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A loadMappingFile() 0 12 2
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