Total Complexity | 5 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
22 | class Json |
||
23 | { |
||
24 | /** |
||
25 | * Returns a string containing the JSON representation of the given input |
||
26 | * |
||
27 | * @access public |
||
28 | * @static |
||
29 | * @param mixed $input |
||
30 | * @throws Exception |
||
31 | * @return string |
||
32 | */ |
||
33 | 89 | public static function encode($input) |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * Returns an array with the contents as described in the given JSON input |
||
42 | * |
||
43 | * @access public |
||
44 | * @static |
||
45 | * @param string $input |
||
46 | * @throws Exception |
||
47 | * @return array |
||
48 | */ |
||
49 | 106 | public static function decode($input) |
|
50 | { |
||
51 | 106 | $array = json_decode($input, true); |
|
52 | 106 | self::_detectError(); |
|
53 | 104 | return $array; |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * Detects JSON errors and raises an exception if one is found |
||
58 | * |
||
59 | * @access private |
||
60 | * @static |
||
61 | * @throws Exception |
||
62 | * @return void |
||
63 | */ |
||
64 | 117 | private static function _detectError() |
|
77 | } |
||
78 | } |
||
79 |