csvxml/classes/CSVXMLValidator.php

55 lines
1.0 KiB
PHP
Raw Normal View History

2021-06-13 23:00:36 +02:00
<?PHP
/**
* Contains a helper class for validation errors.
*
* @author Nathan Eikermann <nathan@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Class holding the information about various errors
2022-03-15 10:30:09 +01:00
* that can occur during validation
2021-06-13 23:00:36 +02:00
*/
2022-03-15 10:30:09 +01:00
final class CSVXMLValidator {
2021-06-13 23:00:36 +02:00
public array $error_msgs;
public array $inv_errors;
public array $depcon_errors;
2021-06-21 23:33:02 +02:00
public function addError(String $error)
{
$this->error_msgs[] = $error;
2022-03-15 10:30:09 +01:00
2021-06-21 23:33:02 +02:00
}
public function addInvError(String $error)
{
$this->inv_errors[] = $error;
2022-03-15 10:30:09 +01:00
2021-06-21 23:33:02 +02:00
}
public function addDepconError(String $error)
{
$this->depcon_errors[] = $error;
2022-03-15 10:30:09 +01:00
2021-06-21 23:33:02 +02:00
}
public function overallErrorCount(): int
{
return count($this->error_msgs)
+ count($this->inv_errors)
+ count($this->depcon_errors);
2022-03-15 10:30:09 +01:00
}
/**
* Constructor
*/
public function __construct()
{
$this->error_msgs = [];
$this->inv_errors = [];
$this->depcon_errors = [];
2021-06-21 23:33:02 +02:00
}
2021-06-13 23:00:36 +02:00
}