Polyfill
10 months ago
AbstractCsv.php
10 months ago
ByteSequence.php
10 months ago
CannotInsertRecord.php
10 months ago
CharsetConverter.php
10 months ago
ColumnConsistency.php
10 months ago
EncloseField.php
10 months ago
EscapeFormula.php
10 months ago
Exception.php
10 months ago
HTMLConverter.php
10 months ago
Info.php
10 months ago
InvalidArgument.php
10 months ago
MapIterator.php
10 months ago
RFC4180Field.php
10 months ago
Reader.php
10 months ago
ResultSet.php
10 months ago
Statement.php
10 months ago
Stream.php
10 months ago
SyntaxError.php
10 months ago
TabularDataReader.php
10 months ago
UnableToProcessCsv.php
10 months ago
UnavailableFeature.php
10 months ago
UnavailableStream.php
10 months ago
Writer.php
10 months ago
XMLConverter.php
10 months ago
functions.php
10 months ago
functions_include.php
10 months ago
SyntaxError.php
56 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 $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 | $duplicates = \array_keys(\array_filter(\array_count_values($header), function (int $value) : bool { |
| 45 | return $value > 1; |
| 46 | })); |
| 47 | $instance = new self('The header record contains duplicate column names.'); |
| 48 | $instance->duplicateColumnNames = $duplicates; |
| 49 | return $instance; |
| 50 | } |
| 51 | public function duplicateColumnNames() : array |
| 52 | { |
| 53 | return $this->duplicateColumnNames; |
| 54 | } |
| 55 | } |
| 56 |