Skip to content

Commit 6f30293

Browse files
authored
Update Entity.php
performance and remove checking to ensure CastException will be thrown when necessary
1 parent fb73e0c commit 6f30293

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

system/Entity.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,7 @@ private function castAsJson($value, bool $asArray = false)
588588
$tmp = ! is_null($value) ? ($asArray ? [] : new \stdClass) : null;
589589
if (function_exists('json_decode'))
590590
{
591-
$strlen = is_string($value) ? strlen($value) : 0;
592-
if (($strlen > 1 && ((strpos($value, '[') === 0 && strrpos($value, ']') === $strlen - 1) || (strpos($value, '{') === 0 && strrpos($value, '}') === $strlen - 1) || (strpos($value, '"') === 0 && strrpos($value, '"') === $strlen - 1))) || is_numeric($value))
591+
if ((is_string($value) && strlen($value) > 1 && in_array($value{0}, ['[','{','"'])) || is_numeric($value))
593592
{
594593
$tmp = json_decode($value, $asArray);
595594

0 commit comments

Comments
 (0)