Completed
Push — master ( ae8e06...3ef7f8 )
by Alexander
8s
created

CallableLocator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 24
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A locateClass() 0 4 1
1
<?php
2
/**
3
 * Parser Reflection API
4
 *
5
 * @copyright Copyright 2015, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Go\ParserReflection\Locator;
12
13
use Composer\Autoload\ClassLoader;
14
use Go\ParserReflection\LocatorInterface;
15
use Go\ParserReflection\ReflectionException;
16
17
/**
18
 * Locator, that can find a file for the given class name by asking composer
19
 */
20
class CallableLocator implements LocatorInterface
21
{
22
    /**
23
     * @var callable
24
     */
25
    private $callable;
26
27 1
    public function __construct(callable $callable)
28
    {
29 1
        $this->callable = $callable;
30 1
    }
31
32
    /**
33
     * Returns a path to the file for given class name
34
     *
35
     * @param string $className Name of the class
36
     *
37
     * @return string|false Path to the file with given class or false if not found
38
     */
39 1
    public function locateClass($className)
40
    {
41 1
        return call_user_func($this->callable, $className);
42
    }
43
}
44