Failed Conditions
Push — new-parser-ast-metadata ( 6127e0...5a4a16 )
by Michael
12s
created

Scope::increaseNestingLevel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Parser;
6
7
use ReflectionClass;
8
use ReflectionFunctionAbstract;
9
use ReflectionProperty;
10
use Reflector;
11
use function assert;
12
13
/**
14
 * Represents the source scope effective at the phpDoc declaration.
15
 *
16
 * @internal
17
 */
18
final class Scope
19
{
20
    /** @var ReflectionClass|ReflectionProperty|ReflectionFunctionAbstract */
21
    private $subject;
22
23
    /** @var Imports */
24
    private $imports;
25
26
    /** @var IgnoredAnnotations */
27
    private $ignoredAnnotations;
28
29
    /** @var int */
30
    private $nestingLevel;
31
32 45
    public function __construct(
33
        Reflector $subject,
34
        Imports $imports,
35
        IgnoredAnnotations $ignoredAnnotations,
36
        int $nestingLevel = 0
37
    ) {
38 45
        assert(
39 45
            $subject instanceof ReflectionClass
40 3
            || $subject instanceof ReflectionProperty
41 45
            || $subject instanceof ReflectionFunctionAbstract
42
        );
43 45
        assert($nestingLevel >= 0);
44
45 45
        $this->subject            = $subject;
46 45
        $this->imports            = $imports;
47 45
        $this->ignoredAnnotations = $ignoredAnnotations;
48 45
        $this->nestingLevel       = $nestingLevel;
49 45
    }
50
51
    /**
52
     * @return ReflectionClass|ReflectionFunctionAbstract|ReflectionProperty
53
     */
54 21
    public function getSubject() : Reflector
55
    {
56 21
        return $this->subject;
57
    }
58
59 23
    public function getImports() : Imports
60
    {
61 23
        return $this->imports;
62
    }
63
64 8
    public function getIgnoredAnnotations() : IgnoredAnnotations
65
    {
66 8
        return $this->ignoredAnnotations;
67
    }
68
69 11
    public function isNested() : bool
70
    {
71 11
        return $this->nestingLevel > 1;
72
    }
73
74 9
    public function increaseNestingLevel() : void
75
    {
76 9
        $this->nestingLevel++;
77 9
    }
78
79 9
    public function decreaseNestingLevel() : void
80
    {
81 9
        assert($this->nestingLevel > 0);
82
83 9
        $this->nestingLevel--;
84 9
    }
85
}
86