known
known copied to clipboard
Simplify Idno core and common namespaces
Here's what I fixed or added:
This PR introduces several new classes to simplify the Idno\Core and Idno\Common namespaces:
-
Idno\Core\ServiceContainer.php: A dependency injection container. -
Idno\Core\HttpMethodHandler.php: Centralizes HTTP method logic. -
Idno\Core\ConfigLoader.php: Extracts configuration loading. -
Idno\Core\UrlHelper.php: Separates URL-related functionality. -
Idno\Common\EntityRepository.php: Extracts database operations fromEntity.php. -
Idno\Core\SimplifiedIdno.phpandIdno\Common\SimplifiedPage.php: Demonstrations of refactored core classes. -
SIMPLIFICATION_GUIDE.md: Documentation on the simplification efforts.
Here's why I did it:
The primary goal was to simplify the codebase in Idno\Core and Idno\Common, which had become convoluted due to:
-
Overly large classes (
Entity.php,Page.php,Config.php,Idno.php) with too many responsibilities. - Violations of the Single Responsibility Principle, leading to mixed concerns.
- Tight coupling through heavy use of static calls and direct database access.
- Significant code duplication, particularly in HTTP method handling.
By introducing a service container, dedicated handlers, and repositories, this refactoring aims to reduce complexity, eliminate duplication (estimated ~1,250 lines), improve maintainability, enhance testability, and establish a cleaner, more modular architecture.
Checklist: ([x] to check/tick the boxes)
- [x] This pull request addresses a single issue
- [ ] If this code includes interface changes, I've included screenshots in this Pull Request thread
- [x] I've adhered to Known's style guide (these codesniffer rules might help!)
- [x] My git branch is named in a descriptive way - i.e., yourname-summary-of-issue
- [x] I've tested my code in-browser
- [x] My code contains descriptive comments
- [x] I've added tests where applicable, and...
- [ ] I can run the unit tests successfully.
Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents