Completed
Push — master ( f4ef0a...d00cab )
by Marco
16s
created

ClassMetadataBuildingContext::addSecondPass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
 *
16
 * This software consists of voluntary contributions made by many individuals
17
 * and is licensed under the MIT license. For more information, see
18
 * <http://www.doctrine-project.org>.
19
 */
20
21
declare(strict_types=1);
22
23
namespace Doctrine\ORM\Mapping;
24
25
use Doctrine\ORM\Mapping\Factory\DefaultNamingStrategy;
26
use Doctrine\ORM\Mapping\Factory\NamingStrategy;
27
use Doctrine\ORM\Reflection\ReflectionService;
28
29
class ClassMetadataBuildingContext
30
{
31
    /** @var AbstractClassMetadataFactory */
32
    private $classMetadataFactory;
33
34
    /** @var ReflectionService */
35
    private $reflectionService;
36
37
    /** @var NamingStrategy */
38
    private $namingStrategy;
39
40
    /**
41
     * @var SecondPass[]
42
     */
43
    protected $secondPassList = [];
44
45
    /**
46
     * @var bool
47
     */
48
    private $inSecondPass = false;
49
50 2135
    public function __construct(
51
        AbstractClassMetadataFactory $classMetadataFactory,
52
        ReflectionService $reflectionService,
53
        ?NamingStrategy $namingStrategy = null
54
    ) {
55 2135
        $this->classMetadataFactory = $classMetadataFactory;
56 2135
        $this->reflectionService    = $reflectionService;
57 2135
        $this->namingStrategy       = $namingStrategy ?: new DefaultNamingStrategy();
58 2135
    }
59
60
    public function getClassMetadataFactory() : AbstractClassMetadataFactory
61
    {
62
        return $this->classMetadataFactory;
63
    }
64
65 2032
    public function getReflectionService() : ReflectionService
66
    {
67 2032
        return $this->reflectionService;
68
    }
69
70 459
    public function getNamingStrategy() : NamingStrategy
71
    {
72 459
        return $this->namingStrategy;
73
    }
74
75
    public function addSecondPass(SecondPass $secondPass) : void
76
    {
77
        $this->secondPassList[] = $secondPass;
78
    }
79
80
    public function isInSecondPass() : bool
81
    {
82
        return $this->inSecondPass;
83
    }
84
85 1935
    public function validate() : void
86
    {
87 1935
        $this->inSecondPass = true;
88
89 1935
        foreach ($this->secondPassList as $secondPass) {
90
            /** @var SecondPass $secondPass */
91
            $secondPass->process($this);
92
        }
93
94 1935
        $this->inSecondPass = false;
95 1935
    }
96
}
97