Completed
Push — master ( 4677f1...4b9138 )
by James
13s queued 10s
created

DirectoryReflectorFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\BackwardCompatibility\Factory;
6
7
use Roave\BetterReflection\Reflector\ClassReflector;
8
use Roave\BetterReflection\SourceLocator\Ast\Locator;
9
use Roave\BetterReflection\SourceLocator\Exception\InvalidDirectory;
10
use Roave\BetterReflection\SourceLocator\Exception\InvalidFileInfo;
11
use Roave\BetterReflection\SourceLocator\Type\AggregateSourceLocator;
12
use Roave\BetterReflection\SourceLocator\Type\DirectoriesSourceLocator;
13
use Roave\BetterReflection\SourceLocator\Type\MemoizingSourceLocator;
14
use Roave\BetterReflection\SourceLocator\Type\SourceLocator;
15
16
/**
17
 * @codeCoverageIgnore
18
 */
19
final class DirectoryReflectorFactory
20
{
21
    /** @var Locator */
22
    private $astLocator;
23
24
    public function __construct(Locator $astLocator)
25
    {
26
        $this->astLocator = $astLocator;
27
    }
28
29
    /**
30
     * @throws InvalidFileInfo
31
     * @throws InvalidDirectory
32
     */
33
    public function __invoke(
34
        string $directory,
35
        SourceLocator $dependencies
36
    ) : ClassReflector {
37
        return new ClassReflector(
38
            new MemoizingSourceLocator(new AggregateSourceLocator([
39
                new DirectoriesSourceLocator([$directory], $this->astLocator),
40
                $dependencies,
41
            ]))
42
        );
43
    }
44
}
45