| Total Complexity | 12 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | class JSON |
||
| 21 | { |
||
| 22 | public static $inputStream = 'php://input'; // this is a setting so that unit tests can provide a fake stream :) |
||
| 23 | 14 | public static function getRequestData($subkey = false) |
|
| 24 | { |
||
| 25 | 14 | if (!$requestText = file_get_contents(static::$inputStream)) { |
|
| 26 | 8 | return false; |
|
| 27 | } |
||
| 28 | |||
| 29 | 7 | $data = json_decode($requestText, true); |
|
| 30 | |||
| 31 | 7 | return $subkey ? $data[$subkey] : $data; |
|
| 32 | } |
||
| 33 | |||
| 34 | 3 | public static function respond($data) |
|
| 38 | } |
||
| 39 | |||
| 40 | 1 | public static function translateAndRespond($data) |
|
| 41 | { |
||
| 42 | 1 | static::respond(static::translateObjects($data)); |
|
| 43 | } |
||
| 44 | |||
| 45 | 1 | public static function error($message) |
|
| 50 | 1 | ]); |
|
| 51 | } |
||
| 52 | |||
| 53 | 54 | public static function translateObjects($input) |
|
| 69 | } |
||
| 70 | } |
||
| 72 |