Failed Conditions
Push — master ( a3e53b...559253 )
by Guilherme
14:58
created

getClassMetadataFactory()   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
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Mapping;
6
7
use Doctrine\DBAL\Platforms\AbstractPlatform;
8
use Doctrine\ORM\Mapping\Factory\DefaultNamingStrategy;
9
use Doctrine\ORM\Mapping\Factory\NamingStrategy;
10
use Doctrine\ORM\Reflection\ReflectionService;
11
12
class ClassMetadataBuildingContext
13
{
14
    /** @var ClassMetadataFactory */
15
    private $classMetadataFactory;
16
17
    /** @var ReflectionService */
18
    private $reflectionService;
19
20
    /** @var AbstractPlatform */
21
    private $targetPlatform;
22
23
    /** @var NamingStrategy */
24
    private $namingStrategy;
25
26
    /** @var SecondPass[] */
27
    protected $secondPassList = [];
28
29
    /** @var bool */
30
    private $inSecondPass = false;
31
32 2107
    public function __construct(
33
        ClassMetadataFactory $classMetadataFactory,
34
        ReflectionService $reflectionService,
35
        AbstractPlatform $targetPlatform,
36
        ?NamingStrategy $namingStrategy = null
37
    ) {
38 2107
        $this->classMetadataFactory = $classMetadataFactory;
39 2107
        $this->reflectionService    = $reflectionService;
40 2107
        $this->targetPlatform       = $targetPlatform;
41 2107
        $this->namingStrategy       = $namingStrategy ?: new DefaultNamingStrategy();
42 2107
    }
43
44 156
    public function getClassMetadataFactory() : ClassMetadataFactory
45
    {
46 156
        return $this->classMetadataFactory;
47
    }
48
49 2000
    public function getReflectionService() : ReflectionService
50
    {
51 2000
        return $this->reflectionService;
52
    }
53
54 339
    public function getTargetPlatform() : AbstractPlatform
55
    {
56 339
        return $this->targetPlatform;
57
    }
58
59 407
    public function getNamingStrategy() : NamingStrategy
60
    {
61 407
        return $this->namingStrategy;
62
    }
63
64
    public function addSecondPass(SecondPass $secondPass) : void
65
    {
66
        $this->secondPassList[] = $secondPass;
67
    }
68
69
    public function isInSecondPass() : bool
70
    {
71
        return $this->inSecondPass;
72
    }
73
74 1952
    public function validate() : void
75
    {
76 1952
        $this->inSecondPass = true;
77
78 1952
        foreach ($this->secondPassList as $secondPass) {
79
            /** @var SecondPass $secondPass */
80
            $secondPass->process($this);
81
        }
82
83 1952
        $this->inSecondPass = false;
84 1952
    }
85
}
86