Failed Conditions
Pull Request — new-parser-ast-metadata (#2)
by Michael
01:51
created

ScopeBuilder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\Annotations\Parser;
6
7
use Doctrine\Annotations\Parser\IgnoredAnnotations;
8
use Doctrine\Annotations\Parser\Imports;
9
use Doctrine\Annotations\Parser\Scope;
10
use ReflectionClass;
11
use Reflector;
12
13
final class ScopeBuilder
14
{
15
    /** @var Reflector */
16
    private $subject;
17
18
    /** @var Imports */
19
    private $imports;
20
21
    /** @var IgnoredAnnotations */
22
    private $ignoredAnnotations;
23
24
    /** @var int */
25
    private $nestingLevel;
26
27
    public function __construct()
28
    {
29
        $this->subject            = new ReflectionClass(self::class);
30
        $this->imports            = new Imports([]);
31
        $this->ignoredAnnotations = new IgnoredAnnotations();
32
        $this->nestingLevel       = 0;
33
    }
34
35
    public function withSubject(Reflector $reflector) : self
36
    {
37
        $this->subject = $reflector;
38
39
        return $this;
40
    }
41
42
    /**
43
     * @param string[] $map
44
     */
45
    public function withImports(array $map) : self
46
    {
47
        $this->imports = new Imports($map);
48
49
        return $this;
50
    }
51
52
    /**
53
     * @param string[] $names
54
     */
55
    public function withIgnoredAnnotations(array $names) : self
56
    {
57
        $this->ignoredAnnotations = new IgnoredAnnotations(...$names);
58
59
        return $this;
60
    }
61
62
    public function withNestingLevel(int $level) : self
63
    {
64
        $this->nestingLevel = $level;
65
66
        return $this;
67
    }
68
69
    public function build() : Scope
70
    {
71
        return new Scope(
72
            $this->subject,
73
            $this->imports,
74
            $this->ignoredAnnotations,
75
            $this->nestingLevel
76
        );
77
    }
78
}
79