Repository navigation
Add CSV strategy and byte order mark enums - #42
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 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
MultiSheetStrategyandByteOrderMarkenums and integrates them intoCsvEngine. - 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_CONCATandCsvEngine::STRATEGY_ZIPwithCsv\MultiSheetStrategycases. The strategy setter and getter now use the enum. Subclass overrides and direct property access must use the new type.Add the
Csv\ByteOrderMarkenum and use it for output marks. The constructor acceptsbomEnabledandmultiSheetStrategy. A nullbomEnableddisables 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 testand 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.