Completed
Push — master ( 034d53...fa2497 )
by Márk
26:41 queued 16:42
created

XmlChecker   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

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
    public static function isValid($xml)
22
    {
23
        $useErrors = libxml_use_internal_errors(true);
24
25
        $isCorrect = simplexml_load_string($xml);
26
27
        libxml_use_internal_errors($useErrors);
28
29
        if (false === $isCorrect) {
30
            throw ParserException::notXml($xml);
31
        }
32
33
        return true;
34
    }
35
}
36