XmlChecker   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 24
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 14 2
1
<?php
2
3
namespace Fxmlrpc\Serialization;
4
5
use Fxmlrpc\Serialization\Exception\ParserException;
6
7
/**
8
 * Class XmlChecker to check is correct XML.
9
 *
10
 * @author Piotr Olaszewski <[email protected]>
11
 */
12
final class XmlChecker
13
{
14
    /**
15
     * @param string $xml
16
     *
17
     * @return bool
18
     *
19
     * @throws ParserException
20
     */
21 2
    public static function isValid($xml)
22
    {
23 2
        $useErrors = libxml_use_internal_errors(true);
24
25 2
        $isCorrect = simplexml_load_string($xml);
26
27 2
        libxml_use_internal_errors($useErrors);
28
29 2
        if (false === $isCorrect) {
30 1
            throw ParserException::notXml($xml);
31
        }
32
33 1
        return true;
34
    }
35
}
36