Skip to content

Refactor: Transfer responsibility from handlers to services. - #273

Merged
arhimede merged 1 commit into
4.0from
refactor-4.0-responsibility-from-handler-to-service
Jun 5, 2024
Merged

Refactor: Transfer responsibility from handlers to services.#273
arhimede merged 1 commit into
4.0from
refactor-4.0-responsibility-from-handler-to-service

Conversation

@alexmerlin

Copy link
Copy Markdown
Member

This PR does the following:

  • provides cleaner handlers, by moving find/throw exeption logic to services
  • removes duplicate checks across the code by having the above checks inside services
  • find* service methods will do one of the following:
    • find the requested entity and return it, allowing the request to continue processing
    • not find the requested entity, throw a NotFoundException, which will pass through the handler and get caught by the HandlerTrait's handle method that returns a 404 Not Found response
  • replaces old /** @ var Class $variable */ annotations with asserts, helping both the IDE and Psalm on inferring types

Signed-off-by: alexmerlin <alex.merlin.1985@gmail.com>
@alexmerlin alexmerlin added the enhancement New feature or request label Jun 5, 2024
@alexmerlin alexmerlin self-assigned this Jun 5, 2024
@github-actions

github-actions Bot commented Jun 5, 2024

Copy link
Copy Markdown

Qodana for PHP

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@arhimede
arhimede merged commit 1510df7 into 4.0 Jun 5, 2024
@alexmerlin
alexmerlin deleted the refactor-4.0-responsibility-from-handler-to-service branch June 5, 2024 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants