AbstractCsv.php
4 days ago
ByteSequence.php
4 days ago
CannotInsertRecord.php
4 days ago
CharsetConverter.php
4 days ago
ColumnConsistency.php
4 days ago
EncloseField.php
4 days ago
EscapeFormula.php
4 days ago
Exception.php
9 months ago
HTMLConverter.php
4 days ago
Info.php
4 days ago
InvalidArgument.php
9 months ago
MapIterator.php
4 days ago
RFC4180Field.php
4 days ago
Reader.php
4 days ago
ResultSet.php
4 days ago
Statement.php
4 days ago
Stream.php
4 days ago
SyntaxError.php
4 days ago
TabularDataReader.php
4 days ago
UnableToProcessCsv.php
9 months ago
UnavailableFeature.php
9 months ago
UnavailableStream.php
9 months ago
Writer.php
4 days ago
XMLConverter.php
4 days ago
functions.php
9 months ago
functions_include.php
9 months ago
CannotInsertRecord.php
60 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * League.Csv (https://csv.thephpleague.com) |
| 5 | * |
| 6 | * (c) Ignace Nyamagana Butera <nyamsprod@gmail.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | declare (strict_types=1); |
| 12 | namespace IAWPSCOPED\League\Csv; |
| 13 | |
| 14 | /** |
| 15 | * Thrown when a data is not added to the Csv Document. |
| 16 | * @internal |
| 17 | */ |
| 18 | class CannotInsertRecord extends Exception |
| 19 | { |
| 20 | /** The record submitted for insertion. */ |
| 21 | protected array $record; |
| 22 | /** Validator which did not validated the data. */ |
| 23 | protected string $name = ''; |
| 24 | /** |
| 25 | * Create an Exception from a record insertion into a stream. |
| 26 | */ |
| 27 | public static function triggerOnInsertion(array $record) : self |
| 28 | { |
| 29 | $exception = new self('Unable to write record to the CSV document'); |
| 30 | $exception->record = $record; |
| 31 | return $exception; |
| 32 | } |
| 33 | /** |
| 34 | * Create an Exception from a Record Validation. |
| 35 | */ |
| 36 | public static function triggerOnValidation(string $name, array $record) : self |
| 37 | { |
| 38 | $exception = new self('Record validation failed'); |
| 39 | $exception->name = $name; |
| 40 | $exception->record = $record; |
| 41 | return $exception; |
| 42 | } |
| 43 | /** |
| 44 | * return the validator name. |
| 45 | * |
| 46 | */ |
| 47 | public function getName() : string |
| 48 | { |
| 49 | return $this->name; |
| 50 | } |
| 51 | /** |
| 52 | * return the invalid data submitted. |
| 53 | * |
| 54 | */ |
| 55 | public function getRecord() : array |
| 56 | { |
| 57 | return $this->record; |
| 58 | } |
| 59 | } |
| 60 |