DirectoryReflectorFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
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
 * @deprecated this class builds a simplistic reflector with a DirectoriesSourceLocator around a given
18
 *             path: that is no longer the preferred approach.
19
 *             Please use {@see \Roave\BackwardCompatibilityCheck\Factory\ComposerInstallationReflectorFactory} instead.
20
 *
21
 * @codeCoverageIgnore
22
 */
23
final class DirectoryReflectorFactory
24
{
25
    /** @var Locator */
26
    private $astLocator;
27
28
    public function __construct(Locator $astLocator)
29
    {
30
        $this->astLocator = $astLocator;
31
    }
32
33
    /**
34
     * @throws InvalidFileInfo
35
     * @throws InvalidDirectory
36
     */
37
    public function __invoke(
38
        string $directory,
39
        SourceLocator $dependencies
40
    ) : ClassReflector {
41
        return new ClassReflector(
42
            new MemoizingSourceLocator(new AggregateSourceLocator([
43
                new DirectoriesSourceLocator([$directory], $this->astLocator),
44
                $dependencies,
45
            ]))
46
        );
47
    }
48
}
49