Completed
Pull Request — master (#6869)
by Michael
17:01
created

ClassMetadataExporter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace Doctrine\ORM\Tools\Export;
21
22
/**
23
 * Class used for converting your mapping information between the
24
 * supported formats: yaml, xml, and php/annotation.
25
 *
26
 * @link    www.doctrine-project.org
27
 * @since   2.0
28
 * @author  Jonathan Wage <[email protected]>
29
 */
30
class ClassMetadataExporter
31
{
32
    /**
33
     * @var array
34
     */
35
    private static $_exporterDrivers = [
36
        'xml' => Driver\XmlExporter::class,
37
        'yaml' => Driver\YamlExporter::class,
38
        'yml' => Driver\YamlExporter::class,
39
        'php' => Driver\PhpExporter::class,
40
        'annotation' => Driver\AnnotationExporter::class
41
    ];
42
43 6
    public function __construct()
44
    {
45 6
        @trigger_error(self::class . ' is deprecated and will be removed in Doctrine 3.0', E_USER_DEPRECATED);
46 6
    }
47
48
    /**
49
     * Registers a new exporter driver class under a specified name.
50
     *
51
     * @param string $name
52
     * @param string $class
53
     *
54
     * @return void
55
     */
56
    public static function registerExportDriver($name, $class)
57
    {
58
        self::$_exporterDrivers[$name] = $class;
59
    }
60
61
    /**
62
     * Gets an exporter driver instance.
63
     *
64
     * @param string      $type The type to get (yml, xml, etc.).
65
     * @param string|null $dest The directory where the exporter will export to.
66
     *
67
     * @return Driver\AbstractExporter
68
     *
69
     * @throws ExportException
70
     */
71 6
    public function getExporter($type, $dest = null)
72
    {
73 6
        if ( ! isset(self::$_exporterDrivers[$type])) {
74
            throw ExportException::invalidExporterDriverType($type);
75
        }
76
77 6
        $class = self::$_exporterDrivers[$type];
78
79 6
        return new $class($dest);
80
    }
81
}
82