Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 21 |
XMLNotValidException | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 21 |
__construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
getErrorList | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 11 |
|||
getFileName | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 7 |
<?php | |
declare(strict_types=1); | |
namespace Siesta\Exception; | |
use Siesta\Util\ArrayUtil; | |
use Siesta\Util\ObjectUtil; | |
/** | |
* @author Gregor Müller | |
*/ | |
class XMLNotValidException extends \Exception implements SiestaException | |
{ | |
const ERROR_MESSAGE = "%s Code : %s Level : %s Column: %s"; | |
/** | |
* @var array | |
*/ | |
protected $errorList; | |
/** | |
* @param $errorList | |
*/ | |
public function __construct(array $errorList) | |
{ | |
$this->errorList = $errorList; | |
} | |
/** | |
* @return string[] | |
*/ | |
public function getErrorList() : array | |
{ | |
$errorMessageList = []; | |
foreach ($this->errorList as $error) { | |
$message = ObjectUtil::getFromObject($error, "message"); | |
$code = ObjectUtil::getFromObject($error, "code"); | |
$level = ObjectUtil::getFromObject($error, "level"); | |
$column = ObjectUtil::getFromObject($error, "column"); | |
$errorMessageList[] = sprintf(self::ERROR_MESSAGE, $message, $code, $level, $column); | |
} | |
return $errorMessageList; | |
} | |
/** | |
* @return string | |
*/ | |
public function getFileName() : string | |
{ | |
$firstError = ArrayUtil::getFromArray($this->errorList, 0); | |
if ($firstError === null) { | |
return "not defined"; | |
} | |
return ObjectUtil::getFromObject($firstError, "file"); | |
} | |
} | |