Failed Conditions
Push — master ( fa7802...d60694 )
by Guilherme
09:27
created

ClassMetadataBuildingContext   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
eloc 21
c 0
b 0
f 0
dl 0
loc 72
ccs 16
cts 24
cp 0.6667
rs 10
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 10 2
A isInSecondPass() 0 3 1
A getTargetPlatform() 0 3 1
A getClassMetadataFactory() 0 3 1
A __construct() 0 10 2
A addSecondPass() 0 3 1
A getNamingStrategy() 0 3 1
A getReflectionService() 0 3 1
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 2142
    public function __construct(
33
        ClassMetadataFactory $classMetadataFactory,
34
        ReflectionService $reflectionService,
35
        AbstractPlatform $targetPlatform,
36
        ?NamingStrategy $namingStrategy = null
37
    ) {
38 2142
        $this->classMetadataFactory = $classMetadataFactory;
39 2142
        $this->reflectionService    = $reflectionService;
40 2142
        $this->targetPlatform       = $targetPlatform;
41 2142
        $this->namingStrategy       = $namingStrategy ?: new DefaultNamingStrategy();
42 2142
    }
43
44
    public function getClassMetadataFactory() : ClassMetadataFactory
45
    {
46
        return $this->classMetadataFactory;
47
    }
48
49 2037
    public function getReflectionService() : ReflectionService
50
    {
51 2037
        return $this->reflectionService;
52
    }
53
54 338
    public function getTargetPlatform() : AbstractPlatform
55
    {
56 338
        return $this->targetPlatform;
57
    }
58
59 458
    public function getNamingStrategy() : NamingStrategy
60
    {
61 458
        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 1947
    public function validate() : void
75
    {
76 1947
        $this->inSecondPass = true;
77
78 1947
        foreach ($this->secondPassList as $secondPass) {
79
            /** @var SecondPass $secondPass */
80
            $secondPass->process($this);
81
        }
82
83 1947
        $this->inSecondPass = false;
84 1947
    }
85
}
86