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

DirectoryReflectorFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

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\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