Completed
Push — master ( 1f59cc...77c58f )
by Ivannis Suárez
04:09
created

DoctrineAdapterLocator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 34
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findFileForClass() 0 10 2
1
<?php
2
/**
3
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Cubiche\Infrastructure\Doctrine\ODM\MongoDB\Metadata\Locator;
12
13
use Doctrine\Common\Persistence\Mapping\MappingException;
14
use Doctrine\Common\Persistence\Mapping\Driver\FileLocator;
15
use Metadata\Driver\FileLocatorInterface;
16
17
/**
18
 * DoctrineAdapterLocator class.
19
 *
20
 * @author Ivannis Suárez Jerez <[email protected]>
21
 */
22
class DoctrineAdapterLocator implements FileLocatorInterface
23
{
24
    /**
25
     * @var FileLocator
26
     */
27
    protected $locator;
28
29
    /**
30
     * DoctrineAdapterLocator constructor.
31
     *
32
     * @param FileLocator $locator
33
     */
34
    public function __construct(FileLocator $locator)
35
    {
36
        $this->locator = $locator;
37
    }
38
39
    /**
40
     * @param \ReflectionClass $class
41
     * @param string           $extension
42
     *
43
     * @return string|null
44
     */
45
    public function findFileForClass(\ReflectionClass $class, $extension)
46
    {
47
        $this->locator->setFileExtension($extension);
48
49
        try {
50
            return $this->locator->findMappingFile($class->getName());
0 ignored issues
show
Bug introduced by
Consider using $class->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
51
        } catch (MappingException $e) {
52
            return;
53
        }
54
    }
55
}
56