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

XMLConfigurator::xml2array()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 3
eloc 4
nc 3
nop 2
crap 3
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