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

CallableLocator::locateClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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