Skip to content

feat: implement KaririCode Configuration Component #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
merged 7 commits into from
Sep 28, 2024
Merged

Conversation

walmir-silva
Copy link
Contributor

Implementation of KaririCode Configuration Component

This pull request introduces the complete implementation of the Configuration Component for the KaririCode Framework, including all core classes, interfaces, loaders, merge strategies, validation, and comprehensive unit tests.

Key Changes

  • Implementation of the main Configuration class
  • Creation of interfaces for Loader, MergeStrategy, Storage, and Validator
  • Implementation of loaders for PHP, JSON, and YAML files
  • Development of merge strategies (OverwriteMerge and StrictMerge)
  • Implementation of TreeMapStorage for efficient configuration storage
  • Creation of AutoValidator for automatic configuration type validation
  • Addition of comprehensive unit tests for all classes and functionalities
  • Inclusion of README files in English and Brazilian Portuguese

Features

  • Support for multiple configuration file formats
  • Hierarchical configuration structure
  • Easy access to configuration values
  • Automatic configuration validation
  • Flexible merge strategies
  • Extensible loader system

Testing

All unit tests have been implemented and pass successfully. Code coverage is over 90%.

Documentation

README.md and README.pt-br.md files have been added, providing an overview of the component, installation instructions, usage examples, and community information.

Next Steps

  • Code review
  • Possible addition of more advanced usage examples
  • Consideration of integration with other KaririCode Framework components

Please carefully review the changes and provide feedback. I'm open to suggestions and improvements.

- Create main Config class for orchestrating configuration management
- Implement interfaces for ConfigManager, Loader, Storage, and MergeStrategy
- Add FileLoader abstract class for common file loading functionality
- Create specific loaders for PHP, YAML, and JSON configuration files
- Implement ArrayStorage and TreeMapStorage for configuration data storage
- Add StrictMerge and OverwriteMerge strategies for configuration merging
- Introduce ConfigException for error handling
- Update project structure for better organization and maintainability
…rall design

- Rename main class from Config to Configuration for clarity
- Implement strict typing and improve type hints
- Add auto-validation with new Validator interface and AutoValidator class
- Refactor to better adhere to SOLID principles
- Improve dependency injection and separation of concerns
- Optimize performance with PHP 8 features (match expression)
- Enhance extensibility for custom validation rules
- Enhance readability in Configuration and TreeMapStorage classes
- Rename variables and methods for better clarity
- Extract complex logic into descriptive helper methods
- Simplify conditional statements
- Improve type safety and consistency
- Removed redundant array recursion handling from validateByType.
- Moved recursive validation of nested arrays to validateConfig for a cleaner separation of concerns.
- Simplified validateByType to focus only on type validation, improving code clarity and reducing duplication.
…figuration

class functionality. Key features of this test suite include:

- Testing loading of various configuration file types (JSON, PHP, YAML)
- Validating nested key structures
- Verifying different merge strategies (Overwrite and Strict)
- Handling errors for invalid files and unsupported formats
- Testing get, set, and has methods
- Validating type handling in configuration values
- Ensuring proper file filtering in getConfigFilesFromDirectory
- Handling non-existent directories in getConfigFilesFromDirectory
…der, PhpLoader, YamlLoader, OverwriteMerge, StrictMerge, TreeMapStorage, and AutoValidator

- Implemented ConfigurationExceptionTest to verify exception handling.
- Created FileLoaderTest to ensure proper file validation.
- Developed JsonLoaderTest, PhpLoaderTest, and YamlLoaderTest to test respective loaders.
- Added OverwriteMergeTest and StrictMergeTest to validate merge strategies.
- Introduced TreeMapStorageTest to confirm storage operations.
- Established AutoValidatorTest to check configuration validation.
- Ensured comprehensive coverage for all new components except ConfigurationTest.php.
- Create English README.md with component overview, features, installation instructions, usage examples, and community information
- Add Portuguese (Brazilian) README.pt-br.md with translated content
- Include badges for language selection, technologies used
- Update documentation links and support information
@walmir-silva walmir-silva merged commit a6e7671 into main Sep 28, 2024
1 check 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.

1 participant