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

SchemaToolProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 61
ccs 0
cts 13
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSchemaTool() 0 8 2
A getSchemaValidator() 0 8 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
    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