Writer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 32
ccs 6
cts 8
cp 0.75
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 4 1
A __construct() 0 9 3
1
<?php
2
/*
3
 * This file is part of the Ariadne Component Library.
4
 *
5
 * (c) Muze <[email protected]>
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 arc\xml;
12
13
/**
14
 * This class allows you to create valid and nicely indented XML strings
15
 * Any method called on it is interpreted as a new XML element to create.
16
 */
17
class Writer {
18
19
    /**
20
     * @var string $indent The string to ident each level with. Default is a tab.
21
     */
22
    public $indent = "\t";
23
24
    /**
25
     * @var string $newLine The string to use as a new line or linebreak. Defaults to \r\n.
26
     */
27
    public $newLine = "\r\n";
28
29
    /**
30
     * @param array $options allows you to set the indent and newLine
31
     * options immediately upon construction
32
     */
33 2
    public function __construct( $options = [])
34
    {
35 2
        $optionList = [ 'indent', 'newLine' ];
36 2
        foreach( $options as $option => $optionValue) {
37
            if (in_array( $option, $optionList )) {
38
                $this->{$option} = $optionValue;
39
            }
40
        }
41 2
    }
42
43 6
    public function __call( $name, $args)
44
    {	
45 6
        return call_user_func_array( [ new NodeList( [], $this ), $name ], $args );
46
    }
47
48
}
49