Completed
Push — master ( 71ab64...07cf6c )
by Vitaly
02:16
created

XMLConfigurator::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php declare(strict_types = 1);
2
/**
3
 * Created by Vitaly Iegorov <[email protected]>.
4
 * on 14.08.16 at 15:55
5
 */
6
namespace samsonframework\container\configurator;
7
8
/**
9
 * XML dependency injection container configuration.
10
 * @author Vitaly Iegorov <[email protected]>
11
 * @author Ruslan Molodyko  <[email protected]>
12
 */
13
class XMLConfigurator
14
{
15 1
    public function configure(string $inputConfiguration) : array
16
    {
17 1
        return $this->xml2array(new \SimpleXMLElement($inputConfiguration));
18
    }
19
20
    /**
21
     * function xml2array
22
     *
23
     * This function is part of the PHP manual.
24
     *
25
     * The PHP manual text and comments are covered by the Creative Commons
26
     * Attribution 3.0 License, copyright (c) the PHP Documentation Group
27
     *
28
     * @author  k dot antczak at livedata dot pl
29
     * @date    2011-04-22 06:08 UTC
30
     * @link    http://www.php.net/manual/en/ref.simplexml.php#103617
31
     * @license http://www.php.net/license/index.php#doc-lic
32
     * @license http://creativecommons.org/licenses/by/3.0/
33
     * @license CC-BY-3.0 <http://spdx.org/licenses/CC-BY-3.0>
34
     */
35 1
    protected function xml2array($xmlObject, $out = array())
36
    {
37 1
        foreach ((array)$xmlObject as $index => $node) {
38 1
            $out[$index] = (is_object($node)) ? $this->xml2array($node) : $node;
39
        }
40
41 1
        return $out;
42
    }
43
}
44