Skip to content

Add CSV strategy and byte order mark enums - #42

Merged
donatj merged 1 commit into
masterfrom
feature/csv-strategy-bom-enums
Nov 10, 2026
Merged

donatj merged 1 commit into
masterfrom
feature/csv-strategy-bom-enums

Conversation

@donatj

@donatj donatj commented Nov 10, 2026

Copy link
Copy Markdown
Member

CSV multi-sheet strategies and byte order marks are represented by constants and byte literals. Dedicated enums give these values clear names.

This is intentionally a breaking change. Replace CsvEngine::STRATEGY_CONCAT and CsvEngine::STRATEGY_ZIP with Csv\MultiSheetStrategy cases. The strategy setter and getter now use the enum. Subclass overrides and direct property access must use the new type.

Add the Csv\ByteOrderMark enum and use it for output marks. The constructor accepts bomEnabled and multiSheetStrategy. A null bomEnabled disables the mark for UTF-8 and enables it for other supported Unicode encodings. Generic UTF-16 and UTF-32 use native byte order for both output data and its mark.

The existing encoding strings and DataSheet storage remain unchanged. Update the example and generated documentation.

Validation on PHP 8.5: make lint test and the MDDoc dry run pass. PHPUnit passes 21 tests with 61 assertions. Tests cover both strategies, constructor options, byte order mark defaults and overrides, native-endian output, and existing CSV fixtures.

@donatj
donatj marked this pull request as ready for review November 10, 2026 22:11
Copilot AI balanced review requested due to automatic review settings November 10, 2026 22:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the CSV enum API changes.

No open issues 🎉

What changed in this PR

This PR introduces enums for CSV multi-sheet strategies and byte order marks, replacing strategy constants with an intentionally breaking, enum-typed API.

Changes:

  • Adds MultiSheetStrategy and ByteOrderMark enums and integrates them into CsvEngine.
  • Adds constructor options for strategy and byte order marks, and aligns generic UTF-16/UTF-32 output with native byte order.
  • Expands integration coverage and updates the example and generated documentation.
File Description
test/​Integration/​CsvIntegrationTest.php Covers strategy selection, mark defaults and overrides, and native-endian output.
src/​Engines/​CsvEngine.php Integrates enums, constructor options, and native-endian encoding.
src/​Engines/​Csv/​MultiSheetStrategy.php Defines concatenated CSV and ZIP export strategies.
src/​Engines/​Csv/​ByteOrderMark.php Defines byte order marks for supported Unicode encodings.
README.md Updates generated API documentation and usage example.
example/​simplecsv.php Selects ZIP export through the constructor using the enum.

Review effort: Balanced

@donatj
donatj merged commit 00411c7 into master Nov 10, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants