Skip to content

Commit 919b3bd

Browse files
authored
Update CastException.php
1 parent ad7c74f commit 919b3bd

1 file changed

Lines changed: 19 additions & 23 deletions

File tree

system/Exceptions/CastException.php

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,26 @@ class CastException extends CriticalError
1313
protected $code = 3;
1414

1515
public static function forInvalidJsonFormatException(int $error)
16-
{
17-
if($error === JSON_ERROR_DEPTH)
16+
{
17+
switch($error)
1818
{
19-
throw new static(lang('Cast.jsonErrorDepth'));
20-
}
21-
else if($error === JSON_ERROR_STATE_MISMATCH)
22-
{
23-
throw new static(lang('Cast.jsonErrorStateMismatch'));
24-
}
25-
else if($error === JSON_ERROR_CTRL_CHAR)
26-
{
27-
throw new static(lang('Cast.jsonErrorCtrlChar'));
28-
}
29-
else if($error === JSON_ERROR_SYNTAX)
30-
{
31-
throw new static(lang('Cast.jsonErrorSyntax'));
32-
}
33-
else if($error === JSON_ERROR_UTF8)
34-
{
35-
throw new static(lang('Cast.jsonErrorUtf8'));
36-
}
37-
else
38-
{
39-
throw new static(lang('Cast.jsonErrorUnknown'));
19+
case JSON_ERROR_DEPTH:
20+
throw new static(lang('Cast.jsonErrorDepth'));
21+
break;
22+
case JSON_ERROR_STATE_MISMATCH:
23+
throw new static(lang('Cast.jsonErrorStateMismatch'));
24+
break;
25+
case JSON_ERROR_CTRL_CHAR:
26+
throw new static(lang('Cast.jsonErrorCtrlChar'));
27+
break;
28+
case JSON_ERROR_SYNTAX:
29+
throw new static(lang('Cast.jsonErrorSyntax'));
30+
break;
31+
case JSON_ERROR_UTF8:
32+
throw new static(lang('Cast.jsonErrorUtf8'));
33+
break;
34+
default:
35+
throw new static(lang('Cast.jsonErrorUnknown'));
4036
}
4137

4238
}

0 commit comments

Comments
 (0)