Skip to content

Commit db5f011

Browse files
committed
reverse method
1 parent 4d910e9 commit db5f011

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/Illuminate/Http/JsonResponse.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,26 @@ public function setData($data = [])
6767
$this->data = json_encode($data, $this->encodingOptions);
6868
}
6969

70-
if ($this->hasJsonError(json_last_error())) {
70+
if (! $this->hasValidJson(json_last_error())) {
7171
throw new InvalidArgumentException(json_last_error_msg());
7272
}
7373

7474
return $this->update();
7575
}
7676

77+
/**
78+
* Determine if an error occured during JSON encoding.
79+
*
80+
* @param int $jsonError
81+
* @return bool
82+
*/
83+
protected function hasValidJson($jsonError)
84+
{
85+
return $jsonError === JSON_ERROR_NONE ||
86+
($jsonError === JSON_ERROR_UNSUPPORTED_TYPE &&
87+
$this->hasEncodingOption(JSON_PARTIAL_OUTPUT_ON_ERROR));
88+
}
89+
7790
/**
7891
* {@inheritdoc}
7992
*/
@@ -85,26 +98,13 @@ public function setEncodingOptions($options)
8598
}
8699

87100
/**
88-
* Checks the JSON encoding option is set.
101+
* Determine if a JSON encoding option is set.
89102
*
90103
* @param int $option
91104
* @return bool
92105
*/
93-
public function isEncodingOptionSet($option)
106+
public function hasEncodingOption($option)
94107
{
95108
return (bool) ($this->encodingOptions & $option);
96109
}
97-
98-
/**
99-
* Checks if error happened during json_encode.
100-
*
101-
* @param int $jsonError
102-
* @return bool
103-
*/
104-
protected function hasJsonError($jsonError)
105-
{
106-
return $jsonError !== JSON_ERROR_NONE &&
107-
($jsonError !== JSON_ERROR_UNSUPPORTED_TYPE ||
108-
! $this->isEncodingOptionSet(JSON_PARTIAL_OUTPUT_ON_ERROR));
109-
}
110110
}

0 commit comments

Comments
 (0)