Completed
Push — master ( 876422...9064ef )
by Daniel
02:39
created

SchemaToolProvider::getSchemaValidator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
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 4
    public function __construct(EntityManagerInterface $entityManager)
48
    {
49 4
        $this->entityManager = $entityManager;
50 4
    }
51
52
    /**
53
     * Get schema tool.
54
     *
55
     * @return SchemaTool
56
     */
57 2
    public function getSchemaTool()
58
    {
59 2
        if (null === $this->schemaTool) {
60 2
            $this->schemaTool = new SchemaTool($this->entityManager);
61 1
        }
62
63 2
        return $this->schemaTool;
64
    }
65
66
    /**
67
     * Get schema validator.
68
     *
69
     * @return SchemaValidator
70
     */
71 2
    public function getSchemaValidator()
72
    {
73 2
        if (null === $this->schemaValidator) {
74 2
            $this->schemaValidator = new SchemaValidator($this->entityManager);
75 1
        }
76
77 2
        return $this->schemaValidator;
78
    }
79
}
80