Created default delegate that returns a JSON response when accepted type is json

This commit is contained in:
Alejandro Celaya
2017-10-13 11:55:14 +02:00
parent 391ef5c323
commit 566940349f
3 changed files with 65 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ class JsonErrorResponseGenerator implements ErrorResponseGeneratorInterface, Sta
* @param Request $request
* @param Response $response
* @return Response
* @throws \InvalidArgumentException
*/
public function __invoke($e, Request $request, Response $response)
{
@@ -31,11 +32,7 @@ class JsonErrorResponseGenerator implements ErrorResponseGeneratorInterface, Sta
], $status);
}
/**
* @param string $responsePhrase
* @return string
*/
protected function responsePhraseToCode($responsePhrase): string
protected function responsePhraseToCode(string $responsePhrase): string
{
return strtoupper(str_replace(' ', '_', $responsePhrase));
}