File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php namespace CodeIgniter \Exceptions ;
2+
3+ /**
4+ * Cast Exceptions.
5+ */
6+ class CastException extends CriticalError
7+ {
8+
9+ /**
10+ * Error code
11+ * @var int
12+ */
13+ protected $ code = 3 ;
14+
15+ public static function forInvalidJsonFormatException (int $ error )
16+ {
17+ if ($ error === JSON_ERROR_DEPTH )
18+ {
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 ' ));
40+ }
41+
42+ }
43+
44+ }
You can’t perform that action at this time.
0 commit comments