| Total Complexity | 9 |
| Total Lines | 106 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 2 | Features | 0 |
| 1 | <?php |
||
| 14 | class XsdError |
||
| 15 | { |
||
| 16 | const WARNING = 'Warning'; |
||
| 17 | const ERROR = 'Error'; |
||
| 18 | const FATAL = 'Fatal'; |
||
| 19 | |||
| 20 | private static $levelMap = [ |
||
| 21 | LIBXML_ERR_WARNING => self::WARNING, |
||
| 22 | LIBXML_ERR_ERROR => self::ERROR, |
||
| 23 | LIBXML_ERR_FATAL => self::FATAL, |
||
| 24 | ]; |
||
| 25 | |||
| 26 | /** @var string */ |
||
| 27 | private $level; |
||
| 28 | |||
| 29 | /** @var string */ |
||
| 30 | private $code; |
||
| 31 | |||
| 32 | /** @var string */ |
||
| 33 | private $message; |
||
| 34 | |||
| 35 | /** @var string */ |
||
| 36 | private $line; |
||
| 37 | |||
| 38 | /** @var string */ |
||
| 39 | private $column; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return XsdError |
||
| 43 | */ |
||
| 44 | public static function fromLibXMLError(\LibXMLError $error) |
||
| 45 | { |
||
| 46 | return new self( |
||
| 47 | isset(self::$levelMap[$error->level]) ? self::$levelMap[$error->level] : 'Unknown', |
||
| 48 | $error->code, |
||
| 49 | $error->message, |
||
| 50 | $error->line, |
||
| 51 | $error->column |
||
| 52 | ); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param string $level |
||
| 57 | * @param string $code |
||
| 58 | * @param string $message |
||
| 59 | * @param string $line |
||
| 60 | * @param string $column |
||
| 61 | */ |
||
| 62 | public function __construct($level, $code, $message, $line, $column) |
||
| 63 | { |
||
| 64 | $this->level = $level; |
||
| 65 | $this->code = $code; |
||
| 66 | $this->message = $message; |
||
| 67 | $this->line = $line; |
||
| 68 | $this->column = $column; |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @return string |
||
| 73 | */ |
||
| 74 | public function getLevel() |
||
| 75 | { |
||
| 76 | return $this->level; |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @return string |
||
| 81 | */ |
||
| 82 | public function getCode() |
||
| 83 | { |
||
| 84 | return $this->code; |
||
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @return string |
||
| 89 | */ |
||
| 90 | public function getMessage() |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @return string |
||
| 97 | */ |
||
| 98 | public function getLine() |
||
| 99 | { |
||
| 100 | return $this->line; |
||
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @return string |
||
| 105 | */ |
||
| 106 | public function getColumn() |
||
| 109 | } |
||
| 110 | |||
| 111 | public function __toString() |
||
| 120 | ); |
||
| 121 | } |
||
| 123 |