You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuOutputFormatter.php 674B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Luticate\Utils;
  3. class LuOutputFormatter
  4. {
  5. public static $APP_VERSION = 1.0;
  6. public static function getResponse()
  7. {
  8. return array(
  9. "version" => self::$APP_VERSION,
  10. "code" => 200,
  11. "success" => true,
  12. "data" => null
  13. );
  14. }
  15. public static function formatSuccess($data)
  16. {
  17. $r = self::getResponse();
  18. $r["data"] = $data;
  19. return $r;
  20. }
  21. public static function formatError($code, $message)
  22. {
  23. $r = self::getResponse();
  24. $r["success"] = false;
  25. $r["code"] = $code;
  26. $r["message"] = $message;
  27. return $r;
  28. }
  29. }