known
known copied to clipboard
Simplify Idno core and common namespaces
Here's what I fixed or added:
-
Idno\Common\Page::getInput: Refactored input retrieval logic to clarify precedence (request > JSON payload > default) and ensure filters are applied correctly, fixing a minor bug. -
Idno\Core\Idno::componentFactory: Simplified the factory method to reduce branching, consolidate class existence and subclass validation, and handle default class instantiation more consistently. -
Idno\Core\Config: Streamlined several boolean and string return helpers (getTitle,getDescription,isPublicSite,multipleSyndicationAccounts,isDefaultConfig) using null coalescing and direct boolean casts. -
Idno\Core\Service: Extracted URL normalization logic into a new private helper methodnormalizeUrlForTokenand reused it ingenerateTokento deduplicate code.
Here's why I did it:
The primary goal was to simplify and clarify code within the Idno\Core and Idno\Common namespaces, as requested. This refactoring addresses areas of complexity, reduces redundant logic, improves readability, and fixes a minor bug in Page::getInput, making the codebase more maintainable and easier to understand.
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!)
- [ ] My git branch is named in a descriptive way - i.e., yourname-summary-of-issue
- [ ] I've tested my code in-browser
- [x] My code contains descriptive comments
- [ ] 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