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
SyntaxError.php
53 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 | use Throwable; |
| 15 | /** |
| 16 | * SyntaxError Exception. |
| 17 | * @internal |
| 18 | */ |
| 19 | class SyntaxError extends Exception |
| 20 | { |
| 21 | /** |
| 22 | * @var array<string> |
| 23 | */ |
| 24 | protected array $duplicateColumnNames = []; |
| 25 | /** |
| 26 | * DEPRECATION WARNING! This class will be removed in the next major point release. |
| 27 | * |
| 28 | * @deprecated since version 9.7.0 |
| 29 | */ |
| 30 | public function __construct(string $message = '', int $code = 0, Throwable $previous = null) |
| 31 | { |
| 32 | parent::__construct($message, $code, $previous); |
| 33 | } |
| 34 | public static function dueToHeaderNotFound(int $offset) : self |
| 35 | { |
| 36 | return new self('The header record does not exist or is empty at offset: `' . $offset . '`'); |
| 37 | } |
| 38 | public static function dueToInvalidHeaderColumnNames() : self |
| 39 | { |
| 40 | return new self('The header record contains non string colum names.'); |
| 41 | } |
| 42 | public static function dueToDuplicateHeaderColumnNames(array $header) : self |
| 43 | { |
| 44 | $instance = new self('The header record contains duplicate column names.'); |
| 45 | $instance->duplicateColumnNames = \array_keys(\array_filter(\array_count_values($header), fn(int $value): bool => $value > 1)); |
| 46 | return $instance; |
| 47 | } |
| 48 | public function duplicateColumnNames() : array |
| 49 | { |
| 50 | return $this->duplicateColumnNames; |
| 51 | } |
| 52 | } |
| 53 |