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

XMLConfigurator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 31
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 4 1
A xml2array() 0 8 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