Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 7af31d3

Browse files
committed
Moved default flag value to a constant.
- per @Ocramius
1 parent f733f35 commit 7af31d3

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/Response/JsonResponse.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ class JsonResponse extends Response
2424
{
2525
use InjectContentTypeTrait;
2626

27+
/**
28+
* Default flags for json_encode; value of:
29+
*
30+
* <code>
31+
* JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_UNESCAPED_SLASHES
32+
* </code>
33+
*
34+
* @const int
35+
*/
36+
const DEFAULT_JSON_FLAGS = 79;
37+
2738
/**
2839
* Create a JSON response with the given data.
2940
*
@@ -42,8 +53,12 @@ class JsonResponse extends Response
4253
* @param int $encodingOptions JSON encoding options to use.
4354
* @throws InvalidArgumentException if unable to encode the $data to JSON.
4455
*/
45-
public function __construct($data, $status = 200, array $headers = [], $encodingOptions = 79)
46-
{
56+
public function __construct(
57+
$data,
58+
$status = 200,
59+
array $headers = [],
60+
$encodingOptions = self::DEFAULT_JSON_FLAGS
61+
) {
4762
$body = new Stream('php://temp', 'wb+');
4863
$body->write($this->jsonEncode($data, $encodingOptions));
4964

0 commit comments

Comments
 (0)