XmlFileFromDomElement   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 2
eloc 11
c 3
b 1
f 0
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WebServCo\Framework\Files;
6
7
final class XmlFileFromDomElement extends AbstractFile implements \WebServCo\Framework\Interfaces\FileInterface
8
{
9
    public function __construct(string $fileName, \DOMElement $domElement, bool $formatOutput = false)
10
    {
11
        $domDocument = new \DOMDocument();
12
        $domDocument->preserveWhiteSpace = false;
13
        if ($formatOutput) {
14
            $domDocument->formatOutput = true;
15
        }
16
        $element = $domDocument->importNode($domElement, true);
17
        $domDocument->appendChild($element);
18
        $fileData = (string) $domDocument->saveXML();
19
20
        // phpcs:ignore SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable
21
        $domDocument = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $domDocument is dead and can be removed.
Loading history...
22
        // phpcs:ignore SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable
23
        $element = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $element is dead and can be removed.
Loading history...
24
25
        parent::__construct($fileName, $fileData, XmlFile::CONTENT_TYPE);
26
    }
27
}
28