CallableLocator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

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 Go\ParserReflection\LocatorInterface;
14
15
/**
16
 * Locator, that can find a file for the given class name by asking composer
17
 */
18
class CallableLocator implements LocatorInterface
19
{
20
    /**
21
     * @var callable
22
     */
23
    private $callable;
24
25 1
    public function __construct(callable $callable)
26
    {
27 1
        $this->callable = $callable;
28 1
    }
29
30
    /**
31
     * Returns a path to the file for given class name
32
     *
33
     * @param string $className Name of the class
34
     *
35
     * @return string|false Path to the file with given class or false if not found
36
     */
37 1
    public function locateClass($className)
38
    {
39 1
        return call_user_func($this->callable, ltrim($className, '\\'));
40
    }
41
}
42