XmlDriver::loadMappingFile()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 15
rs 9.2
c 1
b 0
f 0
cc 4
eloc 9
nc 4
nop 1
1
<?php
2
/**
3
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Cubiche\Infrastructure\Doctrine\ODM\MongoDB\Metadata\Driver;
12
13
use Cubiche\Core\Metadata\Driver\AbstractXmlDriver;
14
15
/**
16
 * XmlDriver class.
17
 *
18
 * @author Ivannis Suárez Jerez <[email protected]>
19
 */
20
abstract class XmlDriver extends AbstractXmlDriver
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function loadMappingFile($file)
26
    {
27
        $result = array();
28
        $xmlElement = simplexml_load_file($file);
29
        foreach (array('document', 'embedded-document', 'mapped-superclass') as $type) {
30
            if (isset($xmlElement->$type)) {
31
                foreach ($xmlElement->$type as $documentElement) {
32
                    $documentName = (string) $documentElement['name'];
33
                    $result[$documentName] = $documentElement;
34
                }
35
            }
36
        }
37
38
        return $result;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    protected function getExtension()
45
    {
46
        return '.mongodb.xml';
47
    }
48
}
49