Skip to content

Commit 60c2e4b

Browse files
Update ResponseMediator.php
1 parent fd2b59a commit 60c2e4b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/Gitlab/HttpClient/Message/ResponseMediator.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
class ResponseMediator
1313
{
1414
/**
15-
* Return the response body as a string or json array if content type is application/json.
15+
* The JSON content type identifier.
16+
*
17+
* @var string
18+
*/
19+
const JSON_CONTENT_TYPE = 'application/json';
20+
21+
/**
22+
* Return the response body as a string or JSON array if content type is JSON.
1623
*
1724
* @param ResponseInterface $response
1825
*
@@ -21,7 +28,7 @@ class ResponseMediator
2128
public static function getContent(ResponseInterface $response)
2229
{
2330
$body = $response->getBody()->__toString();
24-
if (0 === strpos($response->getHeaderLine('Content-Type'), 'application/json')) {
31+
if (0 === strpos($response->getHeaderLine('Content-Type'), self::JSON_CONTENT_TYPE)) {
2532
$content = json_decode($body, true);
2633
if (JSON_ERROR_NONE === json_last_error()) {
2734
return $content;

0 commit comments

Comments
 (0)