Xml   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 28
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A repair() 0 19 2
1
<?php
2
namespace Tzsk\ScrapePod\Helpers;
3
4
use Exception;
5
use tidy;
6
7
class Xml
8
{
9
    /**
10
     * @param string $xml
11
     *
12
     * @return string
13
     * @throws Exception
14
     */
15
    public static function repair($xml)
16
    {
17
        if (class_exists("Tidy") === false) {
18
            throw new Exception("Tidy Class not found", 500);
19
        }
20
21
        $config = [
22
            'indent'     => true,
23
            'input-xml'  => true,
24
            'output-xml' => true,
25
            'wrap'       => false
26
        ];
27
28
        $xml_repaired = new Tidy();
29
        $xml_repaired->parseString($xml, $config, 'utf8');
30
        $xml_repaired->cleanRepair();
31
32
        return $xml_repaired;
33
    }
34
}
35