-
Notifications
You must be signed in to change notification settings - Fork 0
[Release] KaririCode Transformer v1.0.0 🚀 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
- Created initial project directory structure with placeholder files for core components - Added `TransformationResult.php` under `src/Result` for result handling. - Added traits for reusable transformation functions - Created `src/Transformer.php` as the main transformer entry point. These files and folders establish the foundation for the project’s structure without implementation details.
…rmer - Implemented `Transform` attribute in `src/Attribute/Transform.php`: - Extends `BaseProcessorAttribute` to mark properties for transformation processing. - Defined `TransformationResult` interface in `src/Contract/TransformationResult.php`: - Provides contract methods for result validation, error handling, and transformed data retrieval. - Created `TransformerException` in `src/Exception/TransformerException.php`: - Extends `AbstractException` to handle transformer-specific errors. - Added methods `invalidInput`, `invalidFormat`, and `invalidType` with detailed error codes and messages for input type, format, and type validation.
…ality - Updated `AbstractTransformerProcessor` with validation logic: - Added `isValid` and `getErrorKey` methods for validation handling. - Included `guardAgainstInvalidType` method to enforce input type checks. - Enhanced array processors: - `ArrayFlattenTransformer`: added configurable `depth` and `separator` for flattening nested arrays. - `ArrayGroupTransformer`: added grouping logic with `groupBy` and `preserveKeys` options. - `ArrayKeyTransformer`: supports transforming array keys to different cases (`snake`, `camel`, `pascal`, `kebab`) with optional recursion. - `ArrayMapTransformer`: introduced `mapping`, `removeUnmapped`, and `recursive` options for flexible array mapping. - Extended `ArrayTransformerTrait` with case transformation methods: - Added `toCamelCase`, `toPascalCase`, `toSnakeCase`, and `toKebabCase` for consistent key formatting. - Updated `StringTransformerTrait` with additional string manipulation methods: - Added transformations for `toLowerCase`, `toUpperCase`, `toTitleCase`, `toSentenceCase`, and various case conversions.
…unctionality - Updated `DateTransformer`: - Added `inputFormat`, `outputFormat`, `inputTimezone`, and `outputTimezone` options for flexible date transformation. - Enhanced `JsonTransformer`: - Configurable options `assoc`, `depth`, and `encodeOptions` for JSON encoding and decoding with error handling. - Improved `NumberTransformer`: - Added options for decimal control, multipliers, rounding, and separators for number formatting. - Updated string processors: - `CaseTransformer`: Supports multiple case transformations, including lower, upper, title, sentence, camel, pascal, snake, and kebab cases. - `MaskTransformer`: Allows masking strings with custom patterns and pre-defined types (e.g., phone, CPF, CNPJ). - `SlugTransformer`: Generates slugs with custom separators, lowercase option, and locale-based transliteration. - `TemplateTransformer`: Template replacement with configurable placeholders and support for missing value handlers. - Updated `TransformationResult`: - Implements `TransformationResult` contract with methods for validation, error retrieval, and transformed data handling.
- Added `Transformer` contract in `src/Contract/Transformer.php`: - Defines the core interface for all transformers, ensuring consistency across implementations. - Updated `ChainTransformer`: - Enhanced chaining mechanism for sequential processing of transformations. - Improved error handling and data validation during transformation chain execution. - Improved `ConditionalTransformer`: - Added conditional checks to apply transformations based on configurable criteria. - Enhanced logic for validating conditions before executing transformations. - Modified main `Transformer` class in `src/Transformer.php`: - Integrated `Transformer` contract to standardize transformation behavior. - Streamlined method signatures and added additional validation for consistent data processing.
- Updated `ConditionalTransformer`: - Updated `TemplateTransformer`
This commit demonstrates the usage of various transformers in the KaririCode Framework. The demo showcases different transformation capabilities: - Data Formats: * Date format conversion (d/m/Y to Y-m-d) * Number formatting with locale-specific separators * JSON handling with pretty print - String Manipulation: * Phone number masking ((##) #####-####) * Case transformations (camelCase, snake_case) * URL slug generation * Template rendering with variable substitution - Array Operations: * Array key case transformation * Array flattening with dot notation * Array grouping by field
…uguese This commit adds detailed documentation for the KaririCode Transformer component in both English and Brazilian Portuguese. The documentation includes: - Complete usage examples with output samples - Detailed configuration options for each transformer - Real-world examples with practical applications - Code samples for common transformation scenarios Documentation highlights: - String transformation (case, mask, slug) - Data formatting (dates, numbers, currency) - Array manipulation (flattening, grouping, key mapping) - Template processing with examples - Integration examples with other KaririCode components The documentation is structured to serve both international and Brazilian developers, with: - Localized examples - Regional formatting patterns - Culturally appropriate use cases Files added: - README.md (English version) - README.pt-BR.md (Portuguese version)
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.
Overview
This PR introduces the first stable release of KaririCode Transformer, a robust and flexible data transformation component for PHP applications. The component provides a comprehensive set of transformers for common data manipulation needs, with a focus on type safety and ease of use.
What's Included
Core Components
Base Infrastructure
String Transformers
Data Transformers
Array Transformers
Composite Transformers
Documentation
Tests
Technical Details
Dependencies
Breaking Changes
Type Safety
Testing Instructions
make test
Example Usage