Passed
Push — master ( faa376...c7ca4c )
by Tim
17:29 queued 14:52
created

UnparseableXMLException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
c 0
b 0
f 0
dl 0
loc 28
rs 10
wmc 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XML\Exception;
6
7
use LibXMLError;
8
9
use function sprintf;
10
11
/**
12
 */
13
final class UnparseableXMLException extends RuntimeException
14
{
15
    /** @var string[] */
16
    private const array LEVELMAP = [
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 16 at column 24
Loading history...
17
        LIBXML_ERR_WARNING => 'WARNING',
18
        LIBXML_ERR_ERROR   => 'ERROR',
19
        LIBXML_ERR_FATAL   => 'FATAL',
20
    ];
21
22
23
    /**
24
     * Constructor for UnparseableXMLException
25
     *
26
     * @param \LibXMLError $error
27
     */
28
    public function __construct(LibXMLError $error)
29
    {
30
        $message = sprintf(
31
            'Unable to parse XML - "%s[%d]": "%s" in "%s" at line %d on column %d"',
32
            self::LEVELMAP[$error->level],
33
            $error->code,
34
            $error->message,
35
            $error->file ?: '(string)',
36
            $error->line,
37
            $error->column,
38
        );
39
40
        parent::__construct($message);
41
    }
42
}
43