-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Formatter
interface to allow returning complete PSR 7 response
#50
Conversation
dca9c89
to
8ae16b7
Compare
Formatter
interface to allow returning complete PSR 7 response
9f2cecb
to
a14fcec
Compare
Fixed all tests and code style. |
AFAICS all the mutations found by infection are covered by tests :-/ |
@lcobucci please take a look |
@hiqsol sorry, about the delay... way too busy with paid work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you had some urgency here I'll handle this 👍
src/ContentTypeMiddleware.php
Outdated
@@ -66,9 +67,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface | |||
} | |||
|
|||
$contentType = $this->extractContentType($response->getHeaderLine('Content-Type')); | |||
$formatter = $this->formatters[$contentType] ?? null; | |||
$formatter = $this->formatters[$contentType] ?? $this->getNotAcceptableFormatter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm modifying this slightly to ensure that we always have the formatter when instantiating this, which removes a method call from this bit.
It's a very small performance gain for normal PHP usage but for handling things with async php is a nice thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I've chosen the laziest variant exactly for this small gain because this object is just not needed in normal (non error) cases.
But it is such a tiny difference that it is just unimportant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, which is why I'm thinking if it makes sense to actually cache this instance... I mean, in a ideal scenario it will hardly reach that point.
b2410dd
to
7440587
Compare
7440587
to
b738629
Compare
b738629
to
4faacd1
Compare
@hiqsol Alright, I've reorganised your commit and now everything should be passing 👍 |
Providing more flexibility to users and simplifying the API.
4faacd1
to
90b7f26
Compare
After merging it I'll just handle #48 and release v3.0. |
Cool! Thanks! 👍 |
Continuing #49
Not finished: not all tests fixed.
Let me know if it is ok to you and I'll finish.
Pay attention to
ContentTypeMiddleware::NOT_ACCEPTABLE
constant andgetNotAcceptableFormatter()
.It allows redefine formatter for not acceptable case in the formatters map.