Completed
Push — feature/merge-build-stop-step ( d59daf )
by Tom
8s
created

FileWriter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 26
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createByFilepath() 0 14 2
1
<?php
2
3
namespace N98\Magento\Command\Developer\Console\Util\Config;
4
5
class FileWriter extends \DOMDocument
6
{
7
    /**
8
     * @var string
9
     */
10
    protected static $defaultXml = '<config></config>';
11
12
    /**
13
     * @param string $filepath
14
     * @return FileWriter
15
     */
16
    public static function createByFilepath($filepath)
17
    {
18
        $dom = new static('1.0', 'UTF-8');
19
        $dom->formatOutput = true;
20
        $dom->preserveWhiteSpace = false;
21
22
        if (file_exists($filepath)) {
23
            $dom->load($filepath);
24
        } else {
25
            $dom->loadXML(static::$defaultXml);
26
        }
27
28
        return $dom;
29
    }
30
}
31