XmlService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 23
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A write() 0 10 1
A __construct() 0 4 1
1
<?php
2
3
/**
4
 * MÓDULO DE EMISIÓN ELECTRÓNICA F72X
5
 * UBL 2.1
6
 * Version 1.0
7
 * 
8
 * Copyright 2019, Jaime Cruz
9
 */
10
11
namespace F72X\Tools;
12
13
use Sabre\Xml\Service;
14
15
class XmlService extends Service {
16
17
    private $xmlVersion;
18
    private $xmlEncoding;
19
    private $xmlStandalone;
20
    private $xmlIndentString = '    ';
21
22
    public function __construct($xmlVersion = '1.0', $encoding = null, $standalone = null) {
23
        $this->xmlVersion = $xmlVersion;
24
        $this->xmlEncoding = $encoding;
25
        $this->xmlStandalone = $standalone;
26
    }
27
28
    public function write($rootElementName, $value, $contextUri = null) {
29
        $me = $this;
30
        $w = $this->getWriter();
31
        $w->openMemory();
32
        $w->contextUri = $contextUri;
33
        $w->setIndent(true);
34
        $w->setIndentString($me->xmlIndentString);
35
        $w->startDocument($me->xmlVersion, $me->xmlEncoding, $me->xmlStandalone);
36
        $w->writeElement($rootElementName, $value);
37
        return $w->outputMemory();
38
    }
39
40
}
41