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.

LuStringDboArray.php 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: robin
  5. * Date: 2/22/16
  6. * Time: 9:40 PM
  7. */
  8. namespace Luticate\Utils\Dbo;
  9. use Luticate\Utils\LuBusiness;
  10. use Luticate\Utils\LuDbo;
  11. class LuStringDboArray extends LuDbo
  12. {
  13. /**
  14. * @var string[]
  15. */
  16. protected $_array;
  17. public function getArray()
  18. {
  19. return $this->_array;
  20. }
  21. public function setArray($value)
  22. {
  23. $this->_array = $value;
  24. }
  25. public function jsonSerialize()
  26. {
  27. return $this->_array;
  28. }
  29. public static function jsonDeserialize($json)
  30. {
  31. if (!is_array($json)) {
  32. LuBusiness::badInput("Invalid array value");
  33. }
  34. $dbo = new self();
  35. $array = [];
  36. foreach ($json as $data) {
  37. $array[] = LuStringDbo::jsonDeserialize($data)->getString();
  38. }
  39. $dbo->setArray($array);
  40. return $dbo;
  41. }
  42. public static function generateSample()
  43. {
  44. return [
  45. LuStringDbo::generateSample(),
  46. LuStringDbo::generateSample()
  47. ];
  48. }
  49. }