Completed
Push — master ( 9ce2ea...baff27 )
by Daniel
12:24
created

SchemaToolProvider::getSchemaValidator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 5
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 6
1
<?php
2
/**
3
 * This file is part of the Commander project.
4
 *
5
 * @author Daniel Schröder <[email protected]>
6
 */
7
8
namespace GravityMedia\Commander\Provider;
9
10
use Doctrine\ORM\EntityManagerInterface;
11
use Doctrine\ORM\Tools\SchemaTool;
12
use Doctrine\ORM\Tools\SchemaValidator;
13
14
/**
15
 * Schema tool provider class.
16
 *
17
 * @package GravityMedia\Commander\Provider
18
 */
19
class SchemaToolProvider
20
{
21
    /**
22
     * The entity manager.
23
     *
24
     * @var EntityManagerInterface
25
     */
26
    protected $entityManager;
27
28
    /**
29
     * The schema tool.
30
     *
31
     * @var SchemaTool
32
     */
33
    protected $schemaTool;
34
35
    /**
36
     * The schema validator.
37
     *
38
     * @var SchemaValidator
39
     */
40
    protected $schemaValidator;
41
42
    /**
43
     * Create schema tool provider object.
44
     *
45
     * @param EntityManagerInterface $entityManager
46
     */
47
    public function __construct(EntityManagerInterface $entityManager)
48
    {
49
        $this->entityManager = $entityManager;
50
    }
51
52
    /**
53
     * Get schema tool.
54
     *
55
     * @return SchemaTool
56
     */
57
    public function getSchemaTool()
58
    {
59
        if (null === $this->schemaTool) {
60
            $this->schemaTool = new SchemaTool($this->entityManager);
61
        }
62
63
        return $this->schemaTool;
64
    }
65
66
    /**
67
     * Get schema validator.
68
     *
69
     * @return SchemaValidator
70
     */
71
    public function getSchemaValidator()
72
    {
73
        if (null === $this->schemaValidator) {
74
            $this->schemaValidator = new SchemaValidator($this->entityManager);
75
        }
76
77
        return $this->schemaValidator;
78
    }
79
}
80