| Total Complexity | 2 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | final class UnparseableXMLException extends RuntimeException |
||
| 14 | { |
||
| 15 | /** @var string[] */ |
||
| 16 | private const array LEVELMAP = [ |
||
|
|
|||
| 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 | } |
||
| 43 |