| 1 | <?php |
||
| 27 | class InsertionException extends RuntimeException |
||
| 28 | { |
||
| 29 | /** |
||
| 30 | * The record submitted for insertion |
||
| 31 | * |
||
| 32 | * @var array |
||
| 33 | */ |
||
| 34 | protected $data; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Validator which did not validated the data |
||
| 38 | * |
||
| 39 | * @var string |
||
| 40 | */ |
||
| 41 | protected $name = ''; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Create an Exception from a Record row |
||
| 45 | * |
||
| 46 | * @param string[] $record |
||
| 47 | * |
||
| 48 | * @return self |
||
| 49 | */ |
||
| 50 | 2 | public static function createFromCsv(array $record): self |
|
| 57 | |||
| 58 | /** |
||
| 59 | * Create an Exception from a Record row |
||
| 60 | * |
||
| 61 | * @param string $name validator name |
||
| 62 | * @param string[] $data invalid data |
||
| 63 | * |
||
| 64 | * @return self |
||
| 65 | */ |
||
| 66 | 8 | public static function createFromValidator(string $name, array $data): self |
|
| 74 | |||
| 75 | /** |
||
| 76 | * return the validator name |
||
| 77 | * |
||
| 78 | * @return string |
||
| 79 | */ |
||
| 80 | 2 | public function getName(): string |
|
| 84 | |||
| 85 | /** |
||
| 86 | * return the invalid data submitted |
||
| 87 | * |
||
| 88 | * @return array |
||
| 89 | */ |
||
| 90 | 4 | public function getData(): array |
|
| 94 | } |
||
| 95 |