File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -61,4 +61,25 @@ public function getHeaders()
6161 }
6262 return $ headers ;
6363 }
64+
65+ /**
66+ * Override reason phrase handling
67+ *
68+ * If no corresponding reason phrase is available for the current status
69+ * code, return "Unknown Error".
70+ *
71+ * @return string
72+ */
73+ public function getReasonPhrase ()
74+ {
75+ if (! empty ($ this ->reasonPhrase )) {
76+ return $ this ->reasonPhrase ;
77+ }
78+
79+ if (isset ($ this ->recommendedReasonPhrases [$ this ->statusCode ])) {
80+ return $ this ->recommendedReasonPhrases [$ this ->statusCode ];
81+ }
82+
83+ return 'Unknown Error ' ;
84+ }
6485}
Original file line number Diff line number Diff line change @@ -56,4 +56,13 @@ public function testComposeApiProblemIsAccessible()
5656 $ response = new ApiProblemResponse ($ apiProblem );
5757 $ this ->assertSame ($ apiProblem , $ response ->getApiProblem ());
5858 }
59+
60+ /**
61+ * @group 14
62+ */
63+ public function testOverridesReasonPhraseIfStatusCodeIsUnknown ()
64+ {
65+ $ response = new ApiProblemResponse (new ApiProblem (7 , 'Random error ' ));
66+ $ this ->assertContains ('Unknown ' , $ response ->getReasonPhrase ());
67+ }
5968}
You can’t perform that action at this time.
0 commit comments