Completed
Push — master ( b6657b...e9ba9e )
by Rafael
02:42
created

CommonsTrait::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
3
/**
4
 * LICENSE: This file is subject to the terms and conditions defined in
5
 * file 'LICENSE', which is part of this source code package.
6
 *
7
 * @copyright 2016 Copyright(c) - All rights reserved.
8
 */
9
10
namespace Rafrsr\LibArray2Xml;
11
12
trait CommonsTrait
13
{
14
    /**
15
     * @var \DOMDocument|null
16
     */
17
    private static $xml = null;
18
19
    /**
20
     * @var string
21
     */
22
    private static $encoding = 'UTF-8';
23
24
    /**
25
     * @var string
26
     */
27
    private static $prefixAttributes = '@';
28
29
    /**
30
     * Initialize the root XML node [optional]
31
     *
32
     * @param $version
33
     * @param $encoding
34
     * @param $formatOutput
35
     */
36
    public static function init($version = '1.0', $encoding = 'UTF-8', $formatOutput = true)
37
    {
38
        self::$xml = new \DOMDocument($version, $encoding);
39
        self::$xml->formatOutput = $formatOutput;
40
        self::$encoding = $encoding;
41
    }
42
43
    /*
44
    * Get the root XML node, if there isn't one, create it.
45
    */
46
    private static function getXMLRoot()
47
    {
48
        if (self::$xml === null) {
49
            self::init();
50
        }
51
52
        return self::$xml;
53
    }
54
}