| Total Complexity | 5 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php declare(strict_types=1); |
||
| 15 | class ValidationError |
||
| 16 | { |
||
| 17 | const ERROR = 'ERROR'; |
||
| 18 | |||
| 19 | const WARNING = 'WARNING'; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | private $level; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var int |
||
| 28 | */ |
||
| 29 | private $code; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var string |
||
| 33 | */ |
||
| 34 | private $message; |
||
| 35 | |||
| 36 | 7 | private function __construct($level, $code, $message) |
|
| 41 | 7 | } |
|
| 42 | |||
| 43 | 2 | public static function emptyXml() |
|
| 44 | { |
||
| 45 | 2 | return new self(self::ERROR, "", "Provided content is not valid XML."); |
|
| 46 | } |
||
| 47 | |||
| 48 | 5 | public static function fromLibXmlError(\LibXMLError $error) |
|
| 49 | { |
||
| 50 | 5 | return new ValidationError( |
|
| 51 | 5 | \LIBXML_ERR_WARNING == $error->level ? self::WARNING : self::ERROR, |
|
| 52 | 5 | $error->code, |
|
| 53 | 5 | \trim($error->message) |
|
| 54 | ); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @return mixed |
||
| 59 | */ |
||
| 60 | 4 | public function getMessage() |
|
| 63 | } |
||
| 64 | } |
||
| 65 |