File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -231,7 +231,7 @@ private function convertMapperOnInit(mixed $items = null)
231231 return json_decode (json_encode ($ items ), true );
232232 } elseif (is_array ($ items )) {
233233 return $ items ;
234- } elseif ($ this ->isValidJson (( string ) $ items )) {
234+ } elseif ($ this ->isValidJson ($ items )) {
235235 return json_decode ($ items , true );
236236 }
237237
@@ -251,7 +251,7 @@ private function convertOnInit(mixed $items = null)
251251 return json_decode (json_encode ($ items ), true );
252252 } elseif (is_array ($ items )){
253253 return $ items ;
254- } elseif ($ this ->isValidJson (( string ) $ items )) {
254+ } elseif ($ this ->isValidJson ($ items )) {
255255 return json_decode ($ items , true );
256256 }
257257
@@ -261,13 +261,17 @@ private function convertOnInit(mixed $items = null)
261261 /**
262262 * Check if a string is valid JSON.
263263 *
264- * @param string $data
264+ * @param mixed $data
265265 * @return bool
266266 */
267- private function isValidJson (? string $ data = null )
267+ private function isValidJson (mixed $ data = null )
268268 {
269- json_decode ($ data );
270- return json_last_error () === JSON_ERROR_NONE ;
269+ if (is_string ($ data )){
270+ json_decode ($ data );
271+ return json_last_error () === JSON_ERROR_NONE ;
272+ }
273+
274+ return false ;
271275 }
272276
273277}
You can’t perform that action at this time.
0 commit comments