Passed
Pull Request — master (#48)
by Marco
02:59
created

DirectoryReflectorFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\ApiCompare\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\SourceLocator;
14
15
/**
16
 * @codeCoverageIgnore
17
 */
18
final class DirectoryReflectorFactory
19
{
20
    /** @var Locator */
21
    private $astLocator;
22
23
    public function __construct(Locator $astLocator)
24
    {
25
        $this->astLocator = $astLocator;
26
    }
27
28
    /**
29
     * @throws InvalidFileInfo
30
     * @throws InvalidDirectory
31
     */
32
    public function __invoke(
33
        string $directory,
34
        SourceLocator $dependencies
35
    ) : ClassReflector {
36
        return new ClassReflector(
37
            new AggregateSourceLocator([
38
                new DirectoriesSourceLocator([$directory], $this->astLocator),
39
                $dependencies,
40
            ])
41
        );
42
    }
43
}
44