Failed Conditions
Pull Request — new-parser-ast-metadata (#2)
by
unknown
02:33
created

ScopeBuilder   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 22
dl 0
loc 57
rs 10
c 0
b 0
f 0

6 Methods

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