Reduced complexity in HandlerWrapper of CQRS bundle

Reduced complexity in HandlerWrapper of CQRS bundle
Photo by Anastasiia Malai / Unsplash

Two days ago I released a new version (0.5.0) of the CQRS bundle for Symfony. It contains the following changes.

Reduced complexity in the HandlerWrapper

Previously the HandlerWrapper contained 4 steps:

  • prepare
  • catch
  • then
  • finally

When looking through the implementations, I realized that there are no cases that can only be solved by finally. All of them could be solved by a combination of catch and then. On the other hand, there might be issues with a priority when there are multiple HandlerWrappers used where one handles everything with catch and then and another one with finally.

So I removed the finally step entirely. The upgrade to the new version is simple. If you even put anything into finally, simply move it into catch and then.

Made return type of DTOConstructor more specific

It now returns Command|Query instead of just object.

Simply adapt the return type to it in all implementations.

Test coverage

I only realized the problem with the HandlerWrapper, when I wrote tests for the bundle. A nice reminder, that testing leads to better design.

All moving parts now have 100% test code coverage.

Documentation

There is now a warning in the README, that there are breaking changes in the minor versions until it reaches version 1.0. Those breaking changes where are already described in the releases, but are now also documented in the new CHANGELOG file.