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.

LuDbo.php 850B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Luticate\Utils;
  3. abstract class LuDbo implements \JsonSerializable {
  4. /**
  5. * @return string
  6. */
  7. public function __toString()
  8. {
  9. return json_encode($this);
  10. }
  11. /**
  12. * @param $newClass LuDbo
  13. * @return LuDbo
  14. */
  15. public function castAs($newClass) {
  16. $obj = new $newClass;
  17. foreach (get_object_vars($this) as $key => $name) {
  18. $obj->$key = $name;
  19. }
  20. return $obj;
  21. }
  22. /**
  23. * Deserialize from a JSON object
  24. * @param $json mixed The JSON data to deserialize
  25. * @return LuDbo
  26. */
  27. public static function jsonDeserialize($json)
  28. {
  29. return null;
  30. }
  31. /**
  32. * Generate a sample JSON object for the DBO
  33. * @return array
  34. */
  35. public static function generateSample()
  36. {
  37. return null;
  38. }
  39. }