1 | <?php |
||
24 | class CannotInsertRecord extends Exception |
||
25 | { |
||
26 | /** |
||
27 | * The record submitted for insertion |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $record; |
||
32 | |||
33 | /** |
||
34 | * Validator which did not validated the data |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $name = ''; |
||
39 | |||
40 | /** |
||
41 | * Create an Exception from a record insertion into a stream |
||
42 | * |
||
43 | * @param string[] $record |
||
44 | * |
||
45 | * @return self |
||
46 | */ |
||
47 | public static function triggerOnInsertion(array $record): self |
||
48 | { |
||
49 | $exception = new static('Unable to write record to the CSV document'); |
||
50 | $exception->record = $record; |
||
51 | |||
52 | return $exception; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Create an Exception from a Record Validation |
||
57 | * |
||
58 | * @param string $name validator name |
||
59 | * @param string[] $record invalid data |
||
60 | * |
||
61 | * @return self |
||
62 | */ |
||
63 | 6 | public static function triggerOnValidation(string $name, array $record): self |
|
71 | |||
72 | /** |
||
73 | * return the validator name |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | 2 | public function getName(): string |
|
81 | |||
82 | /** |
||
83 | * return the invalid data submitted |
||
84 | * |
||
85 | * @return array |
||
86 | */ |
||
87 | 2 | public function getRecord(): array |
|
91 | } |
||
92 |