Hi, I think this library is great, but why the formatters are responsible to return the final response?
I don't understand this design choice, mainly for these reasons:
- I consider this a violation of SRP: the formatter should only be responsible for formatting the error and returning it to the ErrorHandler. It should not depend on the ResponseFactory and StreamFactory.
- Currently, each FormatterInterface implementation depends on ResponseFactory and StreamFactory. This is acceptable when using the Factory helper, but it makes the dev experience difficult if you need to specify custom implementations.
- Potentially you can specify a different ResponseFactory/StreamFactory implementation for each formatter.
I could prepare a PR for this change, if you want. But it would be potentially a breaking change.